如何在应用程序前面显示对话框 [英] How to show Dialog Box front of application

查看:103
本文介绍了如何在应用程序前面显示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个以dll格式制作该API的软件。

当运行软件API打开一个Dialog并询问Username& 密码。

问题是当我启动软件时它显示软件界面的对话框,显示在工具栏和软件子窗口。



对于创建对话框我使用CreateDialogParam函数。



使用下面的代码创建对话框:

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





对于hWnd我使用软件发送到dll的值。





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,

推荐答案

您使用的是无模式对话框,而不是您需要的对话框。切换到模态对话框(使用 DialogBoxParam function [ ^ ])。当你没有发送任何参数作为参数时,为什么你使用 Param 后缀?另外,不要在函数调用中使用 A 后缀,因为如果您想让代码识别Unicode,就会遇到问题。
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.


这篇关于如何在应用程序前面显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆