Amit
Amit

Reputation: 703

Win API, How to write text inside a dialog box?

I'm creating a small program of my own on WinAPI, (to practice the WIN API programing) and I wanted to create an "about us" box, like where it is told who built the program, which version is it and such...

I was able to create the window sucsessfully, though I could only created an empty window.. I was wondering how can I write text in the box?

This is my function that creates the dialog box, where ghInstance is the instance of the window :

void CreateDialogBox(HWND hwnd)
{
CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_TOPMOST,  TEXT("DialogClass"), TEXT("About Us"), WS_VISIBLE | WS_SYSMENU | WS_CAPTION , 100, 100, 200, 150, NULL, NULL, ghInstance,  NULL);
}

So how can I write inside that empty window some stuff?

Thanks!

Upvotes: 3

Views: 2978

Answers (2)

user2770352
user2770352

Reputation: 97

If you are using MS VC++, you can try editing the pre-made About us in the resource script. Or you hand craft it in a resource script.

DialogboxName DIALOGEX 0, 0, 170, 62
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About Us"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
    ICON            128,IDC_STATIC,14,14,21,20
    LTEXT           "Program by you, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX
    LTEXT           "Copyright (C) 2016",IDC_STATIC,42,26,114,8
    DEFPUSHBUTTON   "OK",IDOK,113,41,50,14,WS_GROUP
END

You can reference Charles Petzold Windows programming book, version 5 of it.

Upvotes: 0

Mike Weir
Mike Weir

Reputation: 3189

This tutorial, provided by Microsoft (MSDN) themselves should come in handy:

http://msdn.microsoft.com/en-us/library/vstudio/bb384843.aspx

Take note of the WM_PAINT section. That's for drawing simple text.

You can also create controls on the window, for example: C++ Win32 Multiline static label

Upvotes: 1

Related Questions