|
Hide your window first by calling ShowWindow(hwnd, SW_HIDE) .
|
|
|
|
|
thanks hans.
that would be fine,but there is always a flash.not perfect.
|
|
|
|
|
You can minimize your application window first and then get the hWnd to the desktop window using the GetDesktopWindow.[^]Then you can maximize your application back again.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
You could manipulate the clipping region for the desktop window before having it paint itself.
|
|
|
|
|
Dear All,
I have a main modeless dialogbox created by CreateDialog and have another child model dialog box created by DialogBox and on this child window I have many button but when I am clicking on any button WM_COMMAND is not getting fired in winproc of child dialog.
I will be very thankful for your support.
With regards
RYK
|
|
|
|
|
There is only a few reasons I can think of why this is happening:
1. Make sure you are looking in the right place for the message. I know it seems trivial, but it happens to everyone.
2. Make sure you set the right MsgProc for the child dialog.
3. Make sure something else isn't replacing the MsgProc for the child dialog (such as MFC)
Spy++ is distributed with Visual Studio, and can be found under the tools menu. Follow these steps to debug using Spy++.
Run your program and open the child dialog where the problems are
Start Spy++ from the Tools menu
Find your child dialog window, either in the list or using the find window toolbar icon
Right click on your child dialog window in the list and select Messages
Click some buttons in your program to see if they show up in the list
You can also check things like check the memory address of the MsgProc and window styles by selecting properties from the right click menu.
|
|
|
|
|
Hi
I'm working on an application that makes use of the MessageBox API. I've written the MessageBox API as:
MessageBox(NULL, sMsg, sTitle, MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
The issue I face is that sometimes when this message box comes on view, it disappears to the background shortly after it displays even though I've specified MB_TASKMODAL.
I replaced MessageBox with AfxMessageBox and the issue seems to be fixed. I no longer have the message box hiding behind other dialogs. I am planning to use AfxMessageBox for the project I am working on.
Could some let me know why this issue occurs and what difference between MessageBox and AfxMessageBox may have fixed the issue?
Thanks
Jens
|
|
|
|
|
MessageBox(NULL, sMsg, sTitle, MB_OK|MB_ICONEXCLAMATION|MB_TASKMODAL);
The first parameter means: "A handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window". For AfxMessageBox you don't need to pass the windows handle.
So this, might be the cause but I might be wrong.
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
AfxMessageBox is a modal dialog of the calling CWnd; MessageBox with a NULL hwnd is a modal dialog of the desktop. Hence, AfxMessageBox will always stay on top of your app, but MessageBox can be hidden by other windows. You can force MessageBox to have the same behavior by using m_hWnd for the first parameter.
|
|
|
|
|
Hans
From what I understand I can still continue using MessageBox by using m_hWnd as the first parameter. What should I declare m_hWnd as? Should it be just an HWnd? If so, what should it be initialized to?
|
|
|
|
|
In MFC, anytime you have any window (such as dialog, view, etc.), that window has a hwnd, which is accessible by the variable m_hWnd , which is declared to be HWND (which is what MessageBox wants).
|
|
|
|
|
A common value for a MFC application is AfxGetMainWnd()->m_hWnd .
AfxGetMainWnd() returns the value you set for m_pMainWnd in the YourApp::InitInstance() function. As the name suggests, it is the main application window.
If you are using it from inside a dialog, you may want to use the dialog HWND instead, although it is not necessary.
|
|
|
|
|
i have a Dialog and ListBox
i created a class to manipulate Controls: CControl
my class have function:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId)
and in Dialog's function:
CControl ctr;
ctr.GetAllProcess(IDC_LIST1,arrProcId);
but can't convert int to CListBox
don't same CSharp
plz Help me...
very clearly if you have a example for me...thanks very much
sorry if my english isn't good
|
|
|
|
|
You have defined the function this way:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId) but you are calling it this way:
ctr.GetAllProcess(IDC_LIST1,arrProcId); .
You can't convert from IDC_LIST1 to a CListCtrl; one is a numeric id, the other is a class. Look at the examples here on Codeproject about how to use the CListCtrl class. Basically, you need to use the resource editor to create a CListCtrl variable; a DDX statement will attach the CListCtrl variable to IDC_LIST1.
And you probably want to write the function like this:
BOOL CControl::GetAllProcess(CListCtrl& list1, int *arrProcId)
|
|
|
|
|
oh thanks for your help ..so much
|
|
|
|
|
You need to use GetDlgItem()[^] to get the window handle from the control ID.
If this is called from within a CWnd derived class this will return a CWnd object which can be cast to the list control. See CWnd::GetDlgItem()[^]
Also, window classes are generally passed around as pointers. At a very minimum they should be passed as a reference as Hans suggested.
Passing by value will create a copy of the class. Properties changed in the copied class may not reflect back on the original.
BOOL CControl::GetAllProcess(CListCtrl *list1, int *arrProcId) {
}
CControl ctr;
ctr.GetAllProcess(GetDlgItem(IDC_LIST1), arrProcId);
|
|
|
|
|
|
Hi,
I am passing a folder path to CFileDialog to save a file to that location. But It can be hidden path. How to pass only visible folder?
Is there any flag I need to pass?
|
|
|
|
|
You should check whether the path is hidden using the WIN32_FIND_DATA structure before passing it to the CFileDialog class. If the folder/file is hidden you need to check it's parent directory and again check if the parent folder is hidden and so on until you get a folder that is visible.
Use the FILE_ATTRIBUTE_HIDDEN attribute to check if the folder is hidden
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
Before calling CFileFolder , call GetFileAttributes() and check the return value for FILE_ATTRIBUTE_HIDDEN .
|
|
|
|
|
hi sir/ mam i am very new to MFC can any one explain how to use HitTest method and what are the uses of it. can we use it for selecting the particular client area.for example i had drawn the text in the client area . had taken two point from LButtonDown and LButtonUP and also the MouseMove and drawn the rectangle by this point. now i want to change the bkcolor of the rectangle .... note i did not taken the editview please any one help me ........
thanking in advance
sarfaraz
|
|
|
|
|
sarfaraznawaz wrote: how to use HitTest method and what are the uses of it
HitTest is normally used to test whether a point is with in the speciifed region or not. You didn't specify the exact context like whether it is windows WM_NCHITTEST or fucntion from any MFC class. Please do.
sarfaraznawaz wrote: had taken two point from LButtonDown and LButtonUP and also the MouseMove and drawn the rectangle by this point. now i want to change the bkcolor of the rectangle
I guess you want o fill the rectangle. Do it by selecting the brush with desired color and style into the DC that you are using to draw.
http://msdn.microsoft.com/en-us/library/dd145175%28v=vs.85%29.aspx
|
|
|
|
|
thanks
i am talking about the WM_NCHITTEST...........
this how i had drawn the rectangle with hollowbrush or NULL_BRUSH because one can see the text..
dc.Rectangle(start_pt.x, start_pt.y, end_pt.x, end_pt.y);
tis are the point which i get from the mouse message LButtonDown and LButtonUP and also the MouseMove....
and now i want to change the color
|
|
|
|
|
Get familiarized with msdn documentation..
WM_NCHITTEST Message
To set the border color of the rectangle you draw, select such a pen to the DC before you call Rectangle() function. To set the fill color do the same with brush. Doesn't it work with you? Have a look at the sample at the link in last post.
|
|
|
|
|
thanks when fill it the text that i have drawn will go hide
|
|
|
|