|
sorry i don't know how to use it..please help with some sample code
|
|
|
|
|
projectip wrote: sorry i don't know how to use it..
And just giving you a wad of code is going to change that? Read here instead.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HI ALL,
Can we use AnimateWindow for CEdit or for Child dialogs.
Thanks in Advance
-@SuDhIrKuMaR@-
|
|
|
|
|
sudhir_Kumar wrote: Can we use AnimateWindow for CEdit or for Child dialogs.
Depends on the flags that are specified. For e.g. AW_BLEND can be used only with top level windows. Also AnimateWindow needs WM_PRINT , WM_PRINTCLIENT to be properly implemented.
Read the docs for more information.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
I have the following code in my applications InitInstance.
CLoginNConfigDlg is the class of a dialog.
CLoginNConfigDlg clncdLoginNConfig;
m_pMainWnd = &clncdLoginNConfig;
HWND hand = clncdLoginNConfig.m_hWnd;
I am not able to get the value of handle in 'hand'.
What am I doing wrong ?
Thanks in advance
|
|
|
|
|
That is because there is no window created yet. A Dialog is created only when you call DoModal (for a modal dialog ofcourse). Try calling this in OnInitDialog member of the dialog class.
-Saurabh
|
|
|
|
|
HANDLE p_Dialog= GetDlgItem(/*handle of dialogbox*/,IDDIALOG);
The GetDlgItem function retrieves a handle to a control in the specified dialog box.
Syntax
<big>
HWND GetDlgItem( HWND hDlg,
int nIDDlgItem
);</big>
Parameters
hDlg
[in] Handle to the dialog box that contains the control.
nIDDlgItem
[in] Specifies the identifier of the control to be retrieved.
Return Value
If the function succeeds, the return value is the window handle of the specified control.
If the function fails, the return value is NULL, indicating an invalid dialog box handle or a nonexistent control. To get extended error information, call GetLastError.
|
|
|
|
|
Nope this doesnt work. GetDlgItem either works in the CDialog derived classes, in that case you can simply use m_hWnd, or it expectes two parameters and first is HWND of the the dialog.
-Saurabh
|
|
|
|
|
Hi,
But if u give the HWND as NULL by default as first parameter it will take the default Dialog handel.
And once the function executes u will get the Dialog handel, as it returns the handel of the window.
|
|
|
|
|
pallaka wrote: But if u give the HWND as NULL by default as first parameter it will take the default Dialog handel.
What is the 'default dialog handle'?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You just pass Hwnd = NULL as parameter.
The return value will be your dialog handel.
try it will work for sure.
|
|
|
|
|
I just tried this and I get NULL pointer on return. I also checked MSDN and it doesn't say anything about first parameter being NULL. In fact it specifically says:
"If the function fails, the return value is NULL, indicating an invalid dialog box handle or a nonexistent control."
I take that as input dialog boc handle must be valid. Can you share you source of information?
-Saurabh
Edit1:
I checked GetLastError after calling GetDlgItem(NULL, IDD_MYDIALOG) and it says Invalid Window Handle.
Edit2:
Okay just saw that you modified your original post to include MSDN documentation.
|
|
|
|
|
an important concept to know in MFC is that window creation and destruction
are TWO STEP PROCESSES....
1) the C++ object - a CWnd or derived object
2) the operating system object - an HWND
You have only created item 1
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Q)the question is my program run without error but it does not display the output
i need to change the setting options in project can any one tell where to change it
my program is a simple win 32 pgm
#include<windows.h>
#include"resource.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASS wc;
MSG msg;
HWND hMainWnd;
if(hPrevInstance!=0)
{
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_MYCURSOR));
wc.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON));
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName="WindowClass";
wc.lpszMenuName=NULL;
}
RegisterClass(&wc);
hMainWnd=CreateWindow("WindowClass","MyfirstWindowsPgm",0,0,0,300,300,NULL,NULL,hInstance,0);
ShowWindow(hMainWnd,nShowCmd);
UpdateWindow(hMainWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hMainWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{ case WM_CREATE: MessageBox(hMainWnd,"Window created","WM_CREATED",MB_OK);
break;
case WM_DESTROY:
MessageBox(hMainWnd,"Window Destroyed","WM_DESTROYED",MB_OKCANCEL);
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
MessageBox(hMainWnd,"left mouse button clicked","WM_LBUTTONDOWN",MB_OK);
break;
default:
return(DefWindowProc(hMainWnd,message,wParam,lParam));
}
return 0;
}
Thanks and Regrads
From Srikanth.Y
|
|
|
|
|
srikanthyenuganti wrote: if(hPrevInstance!=0)
Why are you doing this? Remove this check and application will work fine.
-Saurabh
|
|
|
|
|
thank u
Thanks and Regrads
From Srikanth.Y
|
|
|
|
|
You are welcome.
-Saurabh
|
|
|
|
|
hPrevInstance parameter is kept just for compatibility with Win16 (16 bit) programs.
It will always be NULL for win32 applications.
Regards,
Sandip.
|
|
|
|
|
Q)the question is my program run without error but it does not display the output
i need to change the setting options in project can any one tell where to change it
my program is a simple win 32 pgm
#include<windows.h>
#include"resource.h"
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
WNDCLASS wc;
MSG msg;
HWND hMainWnd;
if(hPrevInstance!=0)
{
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.style=CS_HREDRAW|CS_VREDRAW;
wc.hCursor=LoadCursor(hInstance,MAKEINTRESOURCE(IDC_MYCURSOR));
wc.hIcon=LoadIcon(hInstance,MAKEINTRESOURCE(IDI_MYICON));
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszClassName="WindowClass";
wc.lpszMenuName=NULL;
}
RegisterClass(&wc);
hMainWnd=CreateWindow("WindowClass","MyfirstWindowsPgm",0,0,0,300,300,NULL,NULL,hInstance,0);
ShowWindow(hMainWnd,nShowCmd);
UpdateWindow(hMainWnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hMainWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{ case WM_CREATE: MessageBox(hMainWnd,"Window created","WM_CREATED",MB_OK);
break;
case WM_DESTROY:
MessageBox(hMainWnd,"Window Destroyed","WM_DESTROYED",MB_OKCANCEL);
PostQuitMessage(0);
break;
case WM_LBUTTONDOWN:
MessageBox(hMainWnd,"left mouse button clicked","WM_LBUTTONDOWN",MB_OK);
break;
default:
return(DefWindowProc(hMainWnd,message,wParam,lParam));
}
return 0;
}
Thanks and Regrads
From Srikanth.Y
|
|
|
|
|
Instead of RegisterClass use RegisterClassEx API. Also intialize
wcex.cbSize = sizeof(WNDCLASSEX);
There is no need to change any settings if you are using the wizard.
|
|
|
|
|
the code runned well when i removed if(!PrevInstance)
Thanks and Regrads
From Srikanth.Y
|
|
|
|
|
How can I send messages from one thread to another?
I want to avoid busy/wait loops.
Thank you.
modified 7-Mar-17 16:41pm.
|
|
|
|
|
If a thread has a message queue (for instance GUI threads have it) then you know how to do it.
As for worker threads this page [^] may help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
wow 2 votes of 1 .... i guess i fail any reason why this isn't a good messaging scheme?
|
|
|
|
|