I have C++ dll that using by another software. I need when software call one function of this dll , it shows one Dialog for get user/pwd. My code before worked but in this time not works.
INT_PTR CALLBACK DialogFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
g_hInstance = hModule;
bRun = FALSE;
dwNewLong = 0;
g_Msg = RegisterWindowMessageA("MetaTrader4_Internal_Message");
g_hWnd = FindWindowA("TForm1", "Form1");
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
HWND hWnd1;
int nRet;
char b1[]="VALID";
HWND g_hDlg2,hWnd,hDlg2,hDlg3;
INT_PTR CALLBACK DialogFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
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:
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;
}
int aa=0;
HWND hWnd2;
int dd;
HWND hDlg;
MT4_EXPFUNC int __stdcall INITIAL(HWND hWnd)
{
MSG msg;
BOOL msgstatus;
if(aa==0){
hDlg = CreateDialogParamA(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG1 ), hWnd, DialogFunc, 0);
SetWindowPos( hDlg, HWND_TOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | WS_EX_TOPMOST );
ShowWindow(hDlg, SW_SHOW);
aa=1;
}
dd=result;
hWnd2=hWnd;
return result;
}
I added resource to dll too and compile without problem. but when call this function it not works and not shows dialog box. Any bug in my code? Regards,
CreateDialogParam
does work. Yes there is a bug in your code. What debugging have you done so far? I cannot see any checking of return values in your code. Why not? – David HeffernanDllMain
. – IInspectable