|
Thanks for your reply. My point is this is a new app created by AppWizard and I haven't
added anything. The only code in OnPaint is the declaration of the CPaintDC. It never gets used. I stepped through the construction code for CPaiintDC and I don't see anything to do with the toolbar or the status bar. Its not a problem its just something I noticed and was trying to figure out what one thing had to do with another.
|
|
|
|
|
I have seen a similar issue in a pure Win32 program when not calling BeginPaint() in the handler for the WM_PAINT message. I believe it has something to do with the way messages are cascaded through the windows from the frame down. Bottom line is to leave the basic structure of the wizard generated code intact, especially since you do not know what is under the covers in MFC.
I must get a clever new signature for 2011.
|
|
|
|
|
As Richard MacCutchan also mentioned, this most likely has to do with BeginPaint. I read it somewhere in MSDN that if you do not call this function in response to the WM_PAINT message, WM_PAINT will be re-posted into the message queue until BeginPaint is called in response to make sure a window will be repainted -sooner or later- as needed. I guess, by commenting out CPaintDC, you are flooding your process' message queue with WM_PAINTs, and once this happens, odd things start to happen.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
I have an SDI application that execute an specific moment an thread .From there , I send thorugh ::PostMessage(...) an CString :
CString* pMessage = new CString("Ready");
::PostMessage(m_window,WMU_UPDATE,0,(LPARAM)pMessage);
and , in CMainFrame I receive pMessage in the follow way :
LRESULT CMainFrame::OnUpdate(WPARAM wParam, LPARAM lParam)
{
CString* pMessage = (CString*)lParam;
SetMessageText(*pMessage);
delete pMessage;
}
and goes well , but still , in case that I shut down the application while second thread goes , I have memory leaks :
Dumping objects ->
strcore.cpp(118) : {1945} normal block at 0x003034F0, 268 bytes long.
I have to mention that when I close the application I wait to second thread to stop :
WaitForSingleObject(m_threadHandle, INFINITE);
How can I send CString through ::PostMessage in safe way ?
|
|
|
|
|
Why don't you properly synchronize (e.g. with Critical Section , Mutex ,...) the access to the shared resource (i.e. a CString allocated on the stack by the main thread) and use the message only to notify that the resource has been updated?
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]
|
|
|
|
|
Great ideea ! Now work fine ! Thank you !
|
|
|
|
|
You are welcome.
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]
|
|
|
|
|
Hi . How can I tell the compiler that should compile only VC6 code ? I have the follow code :
BOOL CMainFrame::ShowNotifyBaloon(PTSTR szBalloonTitle, PTSTR szBalloonMsg, DWORD dwIcon , UINT nTimeOut)
{
VERIFY((nTimeOut *= 1000) >= 10000);
ASSERT (dwIcon == NIIF_WARNING || dwIcon == NIIF_ERROR || dwIcon == NIIF_INFO || dwIcon == NIIF_NONE);
m_NID.dwInfoFlags = dwIcon;
m_NID.uFlags |= NIF_INFO;
m_NID.uTimeout = nTimeOut;
::strcpy(m_NID.szInfoTitle,szBalloonTitle);
::strcpy(m_NID.szInfo,szBalloonMsg);
return ::Shell_NotifyIcon(NIM_MODIFY,&m_NID);
}
that is not recognize in VC6 , but is in VC7 .... does exist some an compiler directive to compile only VC6 code and not VC7 code ?
|
|
|
|
|
There are a number of things you can look for. Open your stdafx.h and check
WINVER,_WIN32_WINNT,_WIN32_WINDOWS,_WIN32_IE,_MSC_VER
They define SDK and compiler version. You can use these in #if directives in your code to make it conditional.
|
|
|
|
|
Here is my stdafx.h
#if !defined(AFX_STDAFX_H__B5537D0B_2DD5_11E0_8FF9_0050BF29759A__INCLUDED_)
#define AFX_STDAFX_H__B5537D0B_2DD5_11E0_8FF9_0050BF29759A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h>
#include <afxext.h>
#include <afxdisp.h>
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
and it's about _MSC_VER ? And which version is it ?
|
|
|
|
|
According to MSDN, if you type cl /? at the command line, you will see the full version for the compiler you are using.
Just make sure you know the difference between SDK version and compiler version before you proceed. You might be able to download a later SDK for your old compiler and make it work.
|
|
|
|
|
It should be 1200 for VC6.
|
|
|
|
|
Yes , it's 1200 , because if I write > 1200 won't compile VC7 code , but if I wrote >= 1200 compile VC7 code ,and , of course give error . Thanks !
|
|
|
|
|
I couldn't understand what you want to achieve exactly.
Flaviu 2 wrote: How can I tell the compiler that should compile only VC6 code ?
If you don't want to compile some codes in later releases than VC6. You can use this guard.
#if _MSC_VER <= 1200
...
#endif
But, your problem seems to be related with SDK version rather than compiler version. If so, (that is, a new feature which is not exist older vers,) you should use other macros such as WINVER, _WIN32_WINNT, _WIN32_WINDOWS, _WIN32_IE or _MFC_VER depending on your feature. Or you can use newer SDK as indicated by Niklas. Or may be, you just need to define target platform or similar appropriately on top of stdafx.h.
#define _WIN32_WINDOWS 0x0600
|
|
|
|
|
Hi ,
I have created a .DLL in one solution and I am trying to use that .dll in another solution.
In Visual Studio 2010 if I want to use same .DLL in the same Solution in which it was created , then I can do "Add->References->Configuratio~->Project"
But when I try to use this .DLL in another solution I cannt see .DLL in the "Project" tab.
How can I add reference to dll which is in another solution. MSDN shows the way for adding references of dll only for those which are in same solution.
|
|
|
|
|
Hi,
You can add the existing project to your solution and then add the lib of that dll project in linker options of the project you want add a reference.
Hope this helps
Nitheesh
Nitheesh George
http://www.simpletools.co.in
|
|
|
|
|
Use the Browse tab and add the reference from the folder of the other solution.
|
|
|
|
|
"Browse" is not available in visual studio for a C++ Projects.
|
|
|
|
|
For unmanaged C++ projects, you add a DLL reference as mentioned by Nitheesh George.
Open Project -> Properties -> Configuration Properties -> Linker -> Input .
Enter the name of the LIB file corresponding to the DLL in the Additional Dependencies text box.
|
|
|
|
|
In addition to what Superman said, be sure that the DLL is in the library search path used by Windows so it can be found when your program runs.
I must get a clever new signature for 2011.
|
|
|
|
|
Thanks a lot .
I tried by setting System environment variable,added Library include & Additional dependency and it solved my issue .
|
|
|
|
|
Hello Friends
I want to draw on a image and for that m using FindWindow for its handle and then crating DC and then Graphics Object but after that when I am drawing using drawImage then its drawing above all the windows not on that specific window whose handle m finding.
Here is the code below:
Bitmap gbmp(fileName);
HWND hwnd = FindWindow(...,..);
HDC hdc;
hdc = GetDC(hwnd);
Graphics g(hdc);
g.DrawImage(&gbmp, 500,500, gbmp.GetWidth(), gbmp.GetHeight());
Any Ideas?
Regards
Yogesh
|
|
|
|
|
You will need to convert the coordinates from screen coordinates to window coordinates.
The APIs ClientToScreen and ScreenToClient do this.
Not sure which class/method in GDI+ does this.
|
|
|
|
|
I hope the window you are finding is not the foreground window? Is that correct?
Here is the reason, even though we get separate DC for each window, keep it in mind that the screen space is shared by all the windows.
So if you try to get the DC of window which is not in foreground and when we paint it other than in WM_PAINT cycle then it'll be painted on the shared screen space.
This is why you are seeing the bitmap image at top of all the windows and not in the found window.
Do your Duty and Don't expect the Result
|
|
|
|
|
I have a problem in that the MFC wizard is not generating complete wrapper code for my activex control.
I have a control which I am developing, called CombinedControl. I have in the past added custom properties to that control (and others like it), and generated C++ wrappers using the wizard (select _DCombinedControl interface in Class View, right click; choose Add Property; set property type to DOUBLE, name is Altitude, no params, set 'Get/Set method' check). I build the control, then add an instance of the control to a host dialog in another project, and create a control variable, which appears as a member of the dialog. If all the stars align, the control variable's class will have Get*() and Set*() access methods. The wizard does this by creating a wrapper class (e.g. CCombinedcontrol1) in my host dialog project which implements CWnd and contains the access functions (e.g. CCombinedcontrol1::GetAltitude()).
My problem is that if I return to my ActiveX control and add more properties(e.g. Heading), the wrapper class never generates access functions for them. They are in the IDL for my ActiveX control, and they are in the C++ wrappers for my control class; but the client app's wrapper never generates the access methods (e.g. CCombinedcontrol1::GetHeading()). I get an empty wrapper, with the class defined but access methods absent.
I have done clean builds, deleted and restored the control from the host dialog, unregistered and re-registered the server ... over and over ... all day. I am going nuts.
Any idea what I am doing wrong??
Better yet, what can I do right?
Thanks loads
Eric
PS. VS Pro 2008, particulars follow.
-------------------------------------------------------------------------------------
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Professional
Microsoft Visual Basic 2008 91605-031-5000002-60582
Microsoft Visual Basic 2008
Microsoft Visual C# 2008 91605-031-5000002-60582
Microsoft Visual C# 2008
Microsoft Visual C++ 2008 91605-031-5000002-60582
Microsoft Visual C++ 2008
Microsoft Visual Studio 2008 Tools for Office 91605-031-5000002-60582
Microsoft Visual Studio 2008 Tools for Office
Microsoft Visual Web Developer 2008 91605-031-5000002-60582
Microsoft Visual Web Developer 2008
..hotfixes deleted .... I have the latest service pack.
|
|
|
|