0
votes

How can I get a winMain's HWND hwnd's hInstance application handle without using globals? I'm trying to make a dialog box to be sent to the LRESULT CALLBACK to have certain menu items make it show up. Or is different way to set this up. I've done it with globals already but I can't seem to figure out how to set it up inside the LRESULT CALLBACK I tried

HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hwnd, GWL_HINSTANCE);
HWND hDlgbox = CreateDialog(hInst, MAKEINTRESOURCE(ID_TOOL_BOX_CREATE) ,hwnd, ToolProc);

in the wndproc but that only makes it show up once then never appears again when I try to open it using a popupmenu item and the buttons and items don't seem to receive messages in the dialog box when made this way in the wndproc.

1
Did you try GetModuleHandle(NULL)?Chubsdad
i just tried that i still get the same problem... maybe its the setup inside the winproc? It's still not receiving any messages, is there a way i can send the dialogbox from the winmain to the winproc without using a global?Kevin Heng
So you have some code like MyDialog dlg; dlg.DoModal()?Chubsdad
no i just have it as the code above in the question in the winproc.Kevin Heng
nvm i got it. i'll post my answer belowKevin Heng

1 Answers

0
votes

So what I did was in win main

HWND hdlg;

set wndextra to size of a hwnd.

then create your dlg box however you do it.

SetWindowLongPtr(hwnd, 0, (LONG_PTR)hdlg);

and in winproc hwnd somenewDlg

somenewDlg = (HWND)GetWindowLongPtr(hwnd, 0);