Jump to content
Tuts 4 You

identifiying/keeping appart multiple instances of dialog boxes


deepzero

Recommended Posts

Posted

hi,

so i have been messing with native GUI programming in msvs2008 recently and lots and lots of problems & questions arose... :)

Most of them were exterminated by a quick google search. :)

This one is a little persistent, though:

I have a class, myclass. The user can create multiple instances of that class.

Every class instance has its own instance of a dialog box, which can be displayed at the same time.

How can i now link a class instance to a dialog box?

ie, if the dialog boxes CALLBACK routine is called, how can i know which class instances dialog box send the message?

deep0 :)

Posted (edited)

I don't think I've understood your problem well, but what if you associate a value with each dialogbox handle using SetWindowLong and DWL_USER as parameter after the creation of the dialogbox :

I think of something like (as I don't know your C++ class implementation):

HWND myclass::Create(..){
...
this->hwnd = CreateDialogParam(...);
...
}
void myclass::SetID(DWORD id){
...
SetWindowLong(this->hwnd, DWL_USER, id);
...
}
myclass *mc = new myclass(...);
assert(myclass);
mc->SetID(0xFEADBEEF);...myclass *mc2 = new myclass(...);
assert(myclass);
mc2->SetID(0xFEEDBAAC);

and in the callback function, you can use a switch/case to test against the already known IDs after calling

GetWindowLong(GWL_ID)
Edited by Zool@nder

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...