944,017 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1756
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 30th, 2009
0

Get Dialog hWnd

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  1. contact[atoi(rowC[0])].hWnd = CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG4), hWnd, messengerBox);

messengerBox is defined like this.

C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 94
Solved Threads: 26
Posting Whiz
Excizted is offline Offline
309 posts
since Oct 2009
Oct 30th, 2009
0
Re: Get Dialog hWnd
Quote ...
Hope you understand!
Can't say I do, hWnd will hold the handle to the window being used, so can't you just write:
C++ Syntax (Toggle Plain Text)
  1. ShowWindow(hWnd, SW_HIDE);
If not, you will have to clarify

Posting / Attaching the whole code would help.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 30th, 2009
0
Re: Get Dialog hWnd
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.
C++ Syntax (Toggle Plain Text)
  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?
Reputation Points: 94
Solved Threads: 26
Posting Whiz
Excizted is offline Offline
309 posts
since Oct 2009
Oct 30th, 2009
0
Re: Get Dialog hWnd
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.
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 31st, 2009
0
Re: Get Dialog hWnd
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:

C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 94
Solved Threads: 26
Posting Whiz
Excizted is offline Offline
309 posts
since Oct 2009
Oct 31st, 2009
0
Re: Get Dialog hWnd
Quote ...
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).
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 31st, 2009
0
Re: Get Dialog hWnd
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.
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.
Reputation Points: 94
Solved Threads: 26
Posting Whiz
Excizted is offline Offline
309 posts
since Oct 2009
Oct 31st, 2009
0
Re: Get Dialog hWnd
Quote ...
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
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008
Oct 31st, 2009
0
Re: Get Dialog hWnd
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.
Reputation Points: 94
Solved Threads: 26
Posting Whiz
Excizted is offline Offline
309 posts
since Oct 2009
Oct 31st, 2009
0
Re: Get Dialog hWnd
Click to Expand / Collapse  Quote originally posted by Excizted ...
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
Reputation Points: 1429
Solved Threads: 129
Posting Virtuoso
William Hemsworth is offline Offline
1,542 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Whats wrong with this function?
Next Thread in C++ Forum Timeline: problems with vectors





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC