|
Thanks Mark. I have never used a modeless property sheet but I'll figure it out. I'l post back if i still cant pull it off. Thanks again.
|
|
|
|
|
Hi all,
I faced with an intresting event about GetActiveWindow() method. When I call the code blok below by clicking to a button, I can see the messagebox as "asdasd". But when I call the code blok in a worker thread I cannot see the messagebox.
CWnd *wnd;
wnd = GetActiveWindow();
if(pDlgb == wnd)
MessageBox(_T("asdasd"));
What is the reason for that? Is there any body who can give me an advice about getting the active window in a worker thread?
Thanks,
ibrahim
|
|
|
|
|
Because MFC keeps internal table(s) of (CWnd) windows on a per-thread-basis.
Therefore , the CWnd returned by GetActiveWindow() on a different thread can't possibly
be the same pointer as your pDlgb. It will be a temporary CWnd object also attached to your dialog's
HWND (assuming that window is actually the active window).
Compare the HWNDs instead
if(pDlgb->GetSafeHwnd() == wnd->GetSafeHwnd())
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's a little more complicated than that, although it’s true that MFC's handle maps are thread specific. Here’s how MFC implements CWnd::GetActiveWindow :
_AFXWIN_INLINE CWnd* PASCAL CWnd::GetActiveWindow()
{ return CWnd::FromHandle(::GetActiveWindow()); }
Now the following is from MSDN on the ::GetActiveWindow[^] function:
The GetActiveWindow function retrieves the window handle to the active window attached to the calling thread's message queue.
So ::GetActiveWindow is also thread specific, although you could use the AttachThreadInput[^] to get around this.
Steve
|
|
|
|
|
I'm using VS2008 for a MFC application and I'm having some problems
setting text and background color for a Group-box control.
In previous versions of Visual Studio the following code was working:
HBRUSH CMyPrjView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH l_hBrush = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
int l_iCtrlId;
l_iCtrlId = pWnd->GetDlgCtrlID();
switch(l_iCtrlId)
{
case IDC_STC_GRPBOX_1:
case IDC_STC_GRPBOX_2:
pDC->SetTextColor(RED_COLOR);
pDC->SetBkColor(BLACK_COLOR);
break;
default:
break;
}
return m_cbrshBlack;
}
Now, in VS2008 it doesn't work. I can change all other controls
colors but not for group-box controls. What is changed ?
Is there some properties of the group-box control to be set ?
Or have I to do other things in OnCtlColor ?
Thanks a lot !
|
|
|
|
|
ilgale wrote: Now, in VS2008 it doesn't work.
Are the SetTextColor() and SetBkColor() methods getting called?
"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
|
|
|
|
|
Yes, (look at my code in previous message) but it doesn't work!
|
|
|
|
|
I did look at your code, that's why I asked that question. I saw nothing that indicated those two statements were being executed. Saying that something "does not work" could mean that it executed but produced the wrong result, or that it failed to execute altogether.
"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
|
|
|
|
|
I got your point....
but I've applied a breakpoint for that calls...
I've already verified that are called without any bad results.
|
|
|
|
|
i want to move a buuton to specific position in property sheet
how to move it
|
|
|
|
|
How about MoveWindow() or SetWindowPos() ?
"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
|
|
|
|
|
ya the problem is i derived a sheet from existing property sheet
those buttons are already in their set positions
some buttons i am hiding and i need to move ok cancel can i move
|
|
|
|
|
Member 4655685 wrote: some buttons i am hiding and i need to move ok cancel can i move
So do it in the sheet's OnInitDialog() method.
"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
|
|
|
|
|
CFileDialog f(FALSE,NULL,NULL,OFN_OVERWRITEPROMPT,"Image Files(*.jpg)|*.jpg|Bitmaps(*.bmp)|*.bmp");
if(f.DoModal()==IDOK)
ShellExecute(NULL, _T("save"), f.GetFileName(), NULL, NULL, SW_SHOWNORMAL);
How to modify this code to save an image?
|
|
|
|
|
CopyFile(/*params*/)
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Assuming you have the data that represents the image, call CreateFile() followed by one or more calls to WriteFile() .
"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
|
|
|
|
|
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.
|
|
|
|