|
Sauce! wrote: David I'm not sure what you're getting at.
I was simply suggesting GetDesktopWindow() as a way to get a handle to the desktop window.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
That's what I thought. It's easily doable, but the problem is it gets me nowhere, as that's not the desktop window I'm looking for
Surely someone knows what window the OS draws the actual WALLPAPER to?
|
|
|
|
|
Have you used Spy++ to see the parent/child relationship of the windows in question? It may be different in Vista, but in XP the desktop is the topmost window, and the icons are actually 4 "generations" removed from that.
Desktop
Program Manager
SHELLDLL_DefView
SysListView32
icons I know this does not answer your question, but it may open a door you had previously not considered.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thanks for the response.
I was just looking around in Spy++ tonight (after finally having found a legit download link) and came across the parent/child windows. Funny you should mention it right after I find it.
Setting the render target to the handle for SHELLDLL_DefView seems to do the trick, as the icons show through, however they flicker between frame updates on the screensaver. For example I can see the screensaver and no icons behind it, until I move my cursor over one of the icons (where it should be). The icon then flickers, and disappears until I move the mouse over it again.
Surely there's a way around this! :P
|
|
|
|
|
Actually the wallpaper is not displayed by the desktop, but by a desktop child that is the list control (syslistview) that shows the icons.
Another child is - for example - the taskbar...
|
|
|
|
|
well that's what I thought, but why then, does it render on top of the icons?
I would have thought that the icons and the wallpaper were rendered to seperate controls. Is there any way to keep the icons rendering on top of the wallpaper?
|
|
|
|
|
Sauce! wrote: does it render on top of the icons?
er... not in that sense...
A list control displays icons, text and can have a background.
The order the rendering depends on the WM_PAINT implementation of the control's window procedure (that's a Win32 common control).
The fact they flicker or not depends also on that.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Hi
I have been trying to create my own CButton class. The Button is its own project and is compiled in to the main project as a dependency (win32 project, Static Library, Common header file for: MFC).
Everything worked fine (it reacted when it got pressed and I could start and stop timers). But then I tried to show a dialog from inside the class something went wrong.
The code below shows what I'm trying to do. When I double-click on the button a simple dialog should pop-up. But that does not happen, dlg.DoModal() just returns -1.
class CmyButton : public CButton
{
DECLARE_DYNAMIC(CmyButton)
...
class CmyDialog : public CDialog
{
DECLARE_DYNAMIC(CmyDialog)
...
void CmyButton::OnLButtonDblClk(UINT nFlags, CPoint point)
{
CmyDialog dlg;
dlg.DoModal();
CButton::OnLButtonDblClk(nFlags, point);
}
The project compiles without warnings and everything seems to be found, but the dialog just wont pop-up. But I can show a message-window using AfxMessageBox(_T()).
// Johan
|
|
|
|
|
johanlich wrote: CmyDialog dlg; dlg.DoModal();
If you copy the above code and paste it in the InitInstance of the app, does it shows the dialog correctly?
|
|
|
|
|
Did you use ClassWizard, or equivalent, to create CmyDialog ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I used the ClassWizard to create CmyDialog, and the “Add Resource” tool to create the dialog-window (using MS Visual Studio 2005).
When I copy “CmyDialog dlg; dlg.DoModal()” to InitInstance the main window locks up as if there were a modal window, but the window does not show up on the screen (had to add some #includes into my main apps cpp-file since the CmyButton class is in another catalogue).
Thanks for the quick replies.
// Johan
|
|
|
|
|
In that case the button-thing is irrelevant. It's a problem with your dialog box.
Is the visible style set?
Can you put a breakpoint in the OnInitDialog and see it fire?
You can also set a no-fail-create flag, which is very useful. If there is a problem with a control on the dialog, the whole dialog creation would fail. (Mind you, DoModal should just return almost immediately...)
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi all,
I have a strange issue where an app which I'm getting events from is sometimes producing right click events when a left mouse click is actually what happened. Is there a windows buffer I can read which will allow me to validate the event without having to record all the mouse events myself.
Thanks
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
I'm now using the lines:
SHORT rbstate = GetAsyncKeyState(VK_RBUTTON);
if (!rbstate) {
return;
}
It just makes sure the right mouse button was the one used.
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
Just want to add a little note. GetAsyncKeyState will return the state at the moment you're calling it, which will always be slightly later than the moment the message was generated.
That shouldn't be a problem normally, but you might want to keep that in mind.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Thanks for the response.
GetAsyncKeyState also returns a value > 0 if the key was pressed since the last call to it as well as if the event is currently active. If I'm checking for the right mouse key and someomeone enters the sequence: right key, left key, right key and I make a call each time, I should at least get 0,0 1.
To counteract the first false negative I ignore the first call's result assuming that the first right click event is always correct as in this case the first event is what sets off the problem.
I'm assuming this is what is going on as it now works.
It's not the way I would have chosen. I'll have to keep an eye on it.
Again, thanks for the comment,
Cheers
Tom
Philosophy: The art of never getting beyond the concept of life.
Religion: Morality taking credit for the work of luck.
|
|
|
|
|
I got the below given fatal error while converting a 32 bit application to 64 bit.Any one plz give a solution for this.
Error: mfcs42u.lib(nolib.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
It appears to me quite informative...
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]
|
|
|
|
|
|
thanks for the reply
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
Hi Friends,
I am facing a problem with print preview, actually in the print preview window when we click the print button the preview button closes and print dialog comes up. I want the preview window should not close. Can any one help me how to do that.
thanks,
pradeep
|
|
|
|
|
You may need to create custom preview class.
Have a look at [TN030: Customizing Printing and Print Preview^]
I tried some thing now, sorry i don't have easy solution,
create a new class CMyPreviewView derived from CPreviewView use #include <afxpriv.h> in stdafx.h
overide the Print command handler in the preview view,
BEGIN_MESSAGE_MAP(CMyPreviewView, CPreviewView)
ON_COMMAND(AFX_ID_PREVIEW_PRINT, &CMyPreviewView::OnPreviewPrint)
END_MESSAGE_MAP()
so that you have the control of print button in CMyPreviewView::OnPreviewPrint and here you won't close the preview window
<small>void CMyPreviewView::OnPreviewPrint()
{
m_pOrigView->SendMessage(WM_COMMAND, ID_FILE_PRINT);
}</small>
make your custom preview class as Document preview class by calling DoPrintPreview,
<small>void CMyViewToBePrinted::OnFilePrintPreview()
{
CPrintPreviewState* pState = new CPrintPreviewState;
TRY
{
if (!DoPrintPreview(AFX_IDD_PREVIEW_TOOLBAR, this,
RUNTIME_CLASS(CMyPreviewView), pState))
{
TRACE(traceAppMsg, 0, "Error: DoPrintPreview failed.\n");
AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
delete pState;
}
}
CATCH_ALL(e)
{
delete pState;
THROW_LAST();
}
END_CATCH_ALL
}</small>
modify the View message maps as,
<small>BEGIN_MESSAGE_MAP(CMyViewToBePrinted, CView)
ON_COMMAND(ID_FILE_PRINT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CMyViewToBePrinted::OnFilePrintPreview)
END_MESSAGE_MAP()</small>
|
|
|
|
|
Hi Rajkumar,
Sorry for late reply.
In our application the CPreviewView class was already customized but not the OnPreviewPrint function. so i derived that and added the code. Now when i click the print button in the print preview window the preview window remains and print dialog comes up, but whenever i give OK or CANCEL on the print dialog automatically both the print dialog & preview window closes. I am not understanding why it is happening like that. Did you tried the above in your application, how was the behaviour??
|
|
|
|
|
Not Sure, I don't have time to debug. BTW, in my application, the preview window is not closing when the print dialog cancel button is pressed. You have the complete MFC source code in Visual Studio SDK folder, you can find the reason by debugging them.
|
|
|
|
|
I am using ChooseFont function for selecting font .I want to persist the font data . i.e. when I select the font then they should be reflect in font dailog box when again I call ChooseFont function.How can I achive this.
Trioum
|
|
|
|