-
January 4th, 2014, 12:43 PM
#11
Re: [win32] - creating controls using class's
Code:
void setparent(HWND parent)
{
static int i=i+1;
string strclass=labelclassprop + to_string(i);
labelclassprop=strclass.c_str();
WNDCLASS wc;
HINSTANCE mod = (HINSTANCE)GetModuleHandle(NULL);
ZeroMemory(&wc, sizeof(WNDCLASS));
GetClassInfo(mod, "STATIC", &wc);
wc.hInstance = mod;
wc.lpszClassName = labelclassprop;
wc.hbrBackground = CreateSolidBrush(RGB(255,0,0));
// store the old WNDPROC of the EDIT window class
// store the old WNDPROC of the EDIT window class
SetProp(parent, labelpropname, (HANDLE)wc.lpfnWndProc);
//SetProp(parent, labelclassprop, (HANDLE)this);
//UpdateWindow(hwnd);
// replace it with local WNDPROC
wc.lpfnWndProc = WndProc;
// register the new window class, "ShEdit"
if (!RegisterClass(&wc))
MessageBox(NULL, "error in register", "error", MB_OK);
hwnd = CreateWindowEx(
WS_EX_LEFT| WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_TRANSPARENT,
labelclassprop,
labelclassprop,
SS_LEFT|WS_CHILD|WS_VISIBLE|WS_OVERLAPPED,
100, 100, 100, 100,
parent,
NULL,
mod,
(LPVOID)this);
if (hwnd == NULL)
MessageBox(NULL, "error in create", "error", MB_OK);
//SetProp(parent, labelpropname, (HANDLE)wc.lpfnWndProc);
SetProp(hwnd, labelclassprop, (HANDLE)this);
UpdateWindow(hwnd);
}
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|