Click to See Complete Forum and Search --> : Creating a label (WinAPI)


james2432
June 25th, 2009, 03:10 PM
I've been looking through the documentation of
CreateWindow and CreateWindowEx and I can't seem to find the style to create a basic label with text.

it's probably in static, but then again i'm not too sure

Help would be appreciated.

VictorN
June 25th, 2009, 04:34 PM
What is a "basic label with text"? :confused:

james2432
June 25th, 2009, 04:57 PM
it's like a textbox but with not white or boarders.. basically text to tell the user what the place is for.

http://kornelix.squarespace.com/storage/zfuncstest/zdialog.png?__SQUARESPACE_CACHEVERSION=1229895643489

like the textbeside the fields

ovidiucucu
June 26th, 2009, 02:17 AM
it's probably in static, but then again i'm not too sure
Be sure you need a static common control (of class "static").
Take a look at Static Control Styles (http://msdn.microsoft.com/en-us/library/bb760773(VS.85).aspx).

olivthill2
June 26th, 2009, 09:33 AM
Here is an example where a label is created, with an input field on its right side:

static HWND hwnd_st_u, hwnd_ed_u;
int x, w, y, h;
y = 10; h = 20;
x = 10; w = 50;
hwnd_st_u = CreateWindow("static", "ST_U",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
x, y, w, h,
hwnd, (HMENU)(501),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
SetWindowText(hwnd_st_u, "User:");

x += w; w = 60;
hwnd_ed_u = CreateWindow("edit", "",
WS_CHILD | WS_VISIBLE | WS_TABSTOP
| ES_LEFT | WS_BORDER,
x, y, w, h,
hwnd, (HMENU)(502),
(HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE), NULL);
SetWindowText(hwnd_ed_u, "Bill");