Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have one Software that make for that API in dll format.
When run software API open one Dialog and ask for "Username" & "Password".
Problem is when I start software instead it show dialog front of software screen, shows on Toolbars and subwindow of software.

For create dialog I using CreateDialogParam function.

Use below code to create Dialog:
C++
hDlg = CreateDialogParamA(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG1 ), hWnd, DialogFunc, 0);


For hWnd I using value that software send to dll.

C++
INT_PTR CALLBACK DialogFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	HMENU hMenu;
	
	switch(uMsg)
	{
	case WM_INITDIALOG:
		read(f1);
		read1(f2);
			
		hDlg1=GetDlgItem(hDlg,IDC_EDIT1);
		SetWindowTextA(hDlg1,UserSaved);
		hDlg2=GetDlgItem(hDlg,IDC_EDIT2);
		SetWindowTextA(hDlg2,PWDSaved);
		break;
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDC_BUTTON2:
			char buff1[1024];
			char buff2[1024];
			char buff3[1024];
			
			hDlg3=hDlg;
			
			GetWindowText(hDlg1,username,1024);
			write(f1);
			GetWindowText(hDlg2,key,1024);
			write1(f2);
			if(memcmp(Get_Account_Number_FromWEB(),b1,sizeof(b1))==0 ){result=1; DestroyWindow(hDlg);}
			else MessageBox(0,TEXT("Wrong User or PWD"),0,0);
		  
			break;
			case IDC_BUTTON3:
				DestroyWindow(hDlg);
				break;
				case IDC_EDIT1:
		         break;
			case IDC_EDIT2:
              break;

		}
		break;
	case WM_CLOSE:
		SetWindowLongA(hDlg, GWL_WNDPROC, dwNewLong);
		DestroyWindow(hDlg);
		return TRUE;
		break;
	
	}
	return FALSE;
}


How to set this Dialog shows in front of software screen and not side of screen?
Regards,
Posted
Comments
Marius Bancila 25-Jan-13 8:12am    
I don't get it, sorry. Can you try to explain it again (did you use a translation service?). Maybe showing a picture can help with the language barrier.

1 solution

You are using a modeless dialog which is not what you need. Switch to a modal dialog (use the DialogBoxParam function[^]). And why are you using the Param suffix when you are sending nothing as the parameter? Also, do not use the A suffix on your function calls, as you will have problems if you ever want to make your code Unicode aware.
 
Share this answer
 
Comments
Rezame 25-Jan-13 13:04pm    
I used DialogBoxParam, but when run software, appear Dialog and after close that, main screen start. So How can run both in same time?
Richard MacCutchan 25-Jan-13 13:07pm    
Why do you want to run them at the same time? You are using this dialog to capture the username and password, so the main program should not need to run until the dialog completes.
Rezame 25-Jan-13 13:27pm    
Must run in same time. Because in main software there are other API too and this Dialog using for some parts of screen. Any solution to show both in same time? And dialog on front main software?
Richard MacCutchan 25-Jan-13 13:31pm    
I don't believe that is correct. You need to look at your design, and what you are doing with the information collected from the dialog.
Rezame 25-Jan-13 13:34pm    
Possible show dialog front of screen by CreateDialogParamA function?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900