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:

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

messengerBox is defined like this.

BOOL CALLBACK messengerBox(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
		case WM_COMMAND:
			switch(LOWORD(wParam))
			{
				case WM_DESTROY:
					//ShowWindow(???,SW_HIDE);
				break;
			}
		break;
		default:
			return FALSE;
	}
	return TRUE;
}

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.

Hope you understand!

Can't say I do, hWnd will hold the handle to the window being used, so can't you just write:

ShowWindow(hWnd, SW_HIDE);

If not, you will have to clarify :P

Posting / Attaching the whole code would help.

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.

while(row = get_users_contacts()){
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?

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.

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:

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.hWnd (to hide window) and the contact.id to send a message back.

Cheers for helping :)

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.hWnd (to hide window) and the contact.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).

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.
:)

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 :)

Uhm you want a compilable project or just the code? Because my project has a few dependencis.
MySQL is a killer: 500 MB :P

Edited 7 Years Ago by Excizted: n/a

Uhm you want a compilable project or just the code? Because my project has a few dependencis.
MySQL is a killer: 500 MB :P

I'll stick with just the code please ;)

I'll stick with just the code please ;)

Alright, I'm attaching it here then.
Please dont comment on code not related to my current problem - I'm aware of any problems elsewhere :)

I appreciate your help :D

This article has been dead for over six months. Start a new discussion instead.