Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
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:
hDlg = CreateDialogParamA(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG1 ), hWnd, DialogFunc, 0);
 
For hWnd I using value that software send to dll.
 
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 24-Jan-13 22:31pm
Rezame951
Comments
Marius Bancila at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Rezame at 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 at 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 at 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 at 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 at 25-Jan-13 13:34pm
   
Possible show dialog front of screen by CreateDialogParamA function?
Richard MacCutchan at 26-Jan-13 5:05am
   
Add the <code>WS_EX_TOPMOST</code> style to your dialog.
Rezame at 26-Jan-13 5:09am
   
Thanks. Must add exactly in Which section of Dialog?
Richard MacCutchan at 26-Jan-13 5:11am
   
It's an extended Windows style so it needs to be added to your resource script.
Rezame at 26-Jan-13 5:34am
   
Added this to code SetWindowPos( hDlg, HWND_TOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | WS_EX_TOPMOST ); Now it works. Thanks again.

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

  Print Answers RSS
0 Dnyaneshwar@Pune 1,464
1 Sergey Alexandrovich Kryukov 806
2 OriginalGriff 478
3 sanket saxena 313
4 Tadit Dash 305
0 Sergey Alexandrovich Kryukov 11,700
1 OriginalGriff 6,980
2 Peter Leow 4,915
3 Abhinav S 3,838
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid