Get Dialog hWnd

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 26
Reputation: Excizted is an unknown quantity at this point 
Solved Threads: 0
Excizted Excizted is online now Online
Light Poster

Get Dialog hWnd

 
0
  #1
Oct 30th, 2009
Hi.

I have a problem I cant find a solution to, since I am unable to describe the problem in a searchable way.

I make a hWnd for each contact the user has:

  1. contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);

messengerBox is defined like this.

  1. BOOL CALLBACK messengerBox(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  2. {
  3. switch(message)
  4. {
  5. case WM_COMMAND:
  6. switch(LOWORD(wParam))
  7. {
  8. case WM_DESTROY:
  9. //ShowWindow(???,SW_HIDE);
  10. break;
  11. }
  12. break;
  13. default:
  14. return FALSE;
  15. }
  16. return TRUE;
  17. }

I want the user to be able to hide the dialog - and also get the number of the struct character[] it is in, but I dont know how to get the hWnd, since it is dynamically stored in a variable.

Hope you understand!

Cheers.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,485
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso
 
0
  #2
Oct 30th, 2009
Hope you understand!
Can't say I do, hWnd will hold the handle to the window being used, so can't you just write:
  1. ShowWindow(hWnd, SW_HIDE);
If not, you will have to clarify

Posting / Attaching the whole code would help.
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 26
Reputation: Excizted is an unknown quantity at this point 
Solved Threads: 0
Excizted Excizted is online now Online
Light Poster
 
0
  #3
Oct 30th, 2009
I would know the hWnd for my logon dialog, or my update dialog - but there is a contact dialog for each contact of the user.
  1. while(row = get_users_contacts()){
  2. contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);}

So we have a dialog hWnd in contact[0].hWnd, contact[1].hWnd, etc.
But all these hWnds are linked to the messengerBox (BOOL CALLBACK messengerBox(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)). How do i make hWnd-individual actions in the messengerBox code?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,485
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso
 
0
  #4
Oct 30th, 2009
So let me get this right, you basically have an array of hWnd's which all link to the same event handler, but you want to do different things with each of them in the messengerBox dialog when it's opened.

Even if I understood correctly, it depends what kind of changes will be in each new messengerBox dialog, will it have a totally new layout? or different data in the text fields?

More code, screenshots, anything to describe it better would be helpful.
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 26
Reputation: Excizted is an unknown quantity at this point 
Solved Threads: 0
Excizted Excizted is online now Online
Light Poster
 
0
  #5
Oct 31st, 2009
Originally Posted by William Hemsworth View Post
So let me get this right, you basically have an array of hWnd's which all link to the same event handler, but you want to do different things with each of them in the messengerBox dialog when it's opened.

Even if I understood correctly, it depends what kind of changes will be in each new messengerBox dialog, will it have a totally new layout? or different data in the text fields?

More code, screenshots, anything to describe it better would be helpful.
You do understand correctly. The eventhandler needs to be able to do two things. Hide the window, and send messages.

I have a thread that frequently checks for new messages, and then it sends the message to the textfield in the hWnd as so:

  1. SendMessage(GetDlgItem(contact[atoi(row[2])].hWnd,IDC_EDIT1), WM_SETTEXT, 0, (LPARAM) convertCharTCHAR(row[3]));
Row[2] contains the sender ID, so we send the text to the dialog matching ID with sender ID.

This works fine.

Now I want to be able to, from the dialog, send messages, but I cant figure out how to sepparate the dialogs and get the contact[i].hWnd (to hide window) and the contact[i].id to send a message back.

Cheers for helping
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,485
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso
 
0
  #6
Oct 31st, 2009
Now I want to be able to, from the dialog, send messages, but I cant figure out how to sepparate the dialogs and get the contact[i].hWnd (to hide window) and the contact[i].id to send a message back.
Obviously the use of arrays here has made this very confusing, maybe it's possibly to do without, I don't know. But all I can suggest is to try using global variables and message notifications too, at this stage in making the program you have the biggest understanding of the problem and your intentions, so it's easiest for you to solve (unless perhaps I take a look at the entire project).
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 26
Reputation: Excizted is an unknown quantity at this point 
Solved Threads: 0
Excizted Excizted is online now Online
Light Poster
 
0
  #7
Oct 31st, 2009
Originally Posted by William Hemsworth View Post
So let me get this right, you basically have an array of hWnd's which all link to the same event handler, but you want to do different things with each of them in the messengerBox dialog when it's opened.

Even if I understood correctly, it depends what kind of changes will be in each new messengerBox dialog, will it have a totally new layout? or different data in the text fields?

More code, screenshots, anything to describe it better would be helpful.
Originally Posted by William Hemsworth View Post
Obviously the use of arrays here has made this very confusing, maybe it's possibly to do without, I don't know. But all I can suggest is to try using global variables and message notifications too, at this stage in making the program you have the biggest understanding of the problem and your intentions, so it's easiest for you to solve (unless perhaps I take a look at the entire project).
Well I have used many hours, and unlike normally, I'm completely clueless.
I'd be very glad if you could help me, and I could send over my project if thats what it takes. Its a bit too long to be posted here.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,485
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso
 
0
  #8
Oct 31st, 2009
Well I have used many hours, and unlike normally, I'm completely clueless.
I'd be very glad if you could help me, and I could send over my project if thats what it takes. Its a bit too long to be posted here.
It's worth a shot, just copy the project, delete unneeded compiler generated files, zip it and attach here
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 26
Reputation: Excizted is an unknown quantity at this point 
Solved Threads: 0
Excizted Excizted is online now Online
Light Poster
 
0
  #9
Oct 31st, 2009
Uhm you want a compilable project or just the code? Because my project has a few dependencis.
MySQL is a killer: 500 MB
Last edited by Excizted; Oct 31st, 2009 at 8:42 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,485
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is online now Online
Nearly a Posting Virtuoso
 
0
  #10
Oct 31st, 2009
Originally Posted by Excizted View Post
Uhm you want a compilable project or just the code? Because my project has a few dependencis.
MySQL is a killer: 500 MB
I'll stick with just the code please
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC