|
|
Hi,
i m taking help of this article for design outlook style
Outlookbar-style menu interface[^]
i m using COutlook2Ctrl::OCL_SELECT for trigger with assign Menu Item,in menu item this is disable by CCmdUI,
but please tell me how can i disable this purticular subitem in this outlook tree.
please help me for this.
thanks in advance.
|
|
|
|
|
Generally,singleton pattern is applied by the way that the ctor is private and gives a member funtion named getInstance, but CWinApp's instance is defined as a global object,its ctor is not private.So how MFC realizes the singleton pattern for CWinApp?
|
|
|
|
|
The CWinApp class is not a singleton class.
It doesn't need to be because MFC needs this class has to be created before it internally calls WinMain .
If it was designed as a singleton, you would be able to create it only after WinMain in called and also you would need to write WinMain yourself.
That is why you create a global instance of it and you must create only one as the documentation says.
This is as easy as saying that you can only have one main or WinMain function.
|
|
|
|
|
I Made a test .If i instance another global CWinApp descendant class.In release mode ,there is only one instance in the application ,but not two.How does MFC keep only one CWinApp descendant instance in the application?
|
|
|
|
|
This works in Release mode because the ASSERT macro has no effect in Release mode.
MFC maintains several global functions whose begin with Afx and several global variables whose names begin with _afx .
These are the variables that are used to invoke the various methods in the code.
These variables will be overwritten by the second instance of CWinApp .
So only the last instance of CWinApp will be the valid object.
All the rest will simply occupy space in memory.
|
|
|
|
|
wonderful!I got it ,thank you!
|
|
|
|
|
I recently created a driver installation program, which uses a number of core functions such as UpdateDriverforPlugAndDevice(), using vs2008, in 32-bit operating system everything is working properly. But win32 program can run in x64, but under x64 it does not work. For example UpdateDriverForPlugandPlayDevices() raises an error, I used GetLastError (), and I see an error code. Later I was using a 64-bit system with vs2008 and compiled the x64 program, everything works fine, but the program can not run in win32. The problem is now solved, but I now maintain two versions of the installer 32 and 64; I do not know what a better way, I just run a seperate version of the executable.
|
|
|
|
|
When 32-bit apps try to access certain folders or registry keys in a 64-bit environment, they will be redirected to another path.
For example, drivers are normally copied to C:\Windows\System32\drivers .
When a 32-bit app tries to copy a driver to this location, it will redirected to C:\Windows\SysWOW64\drivers .
This is probably what is going on in you case and so you will have to maintain 2 separate versions of your installer program.
|
|
|
|
|
I get a crash on a Windows Message!
Looked it up in WinUser.h and didn't find anything for it.
This is the MSG number 274.
As it appears when I press close on my Window, my program is receiving a WM_SYSCOMMAND.
This is totally a new thing, I already have a WM_CLOSE.
Can't understand what is triggering it.
modified on Wednesday, July 21, 2010 9:04 PM
|
|
|
|
|
WM_CLOSE is not the last message that an application will receive.
This is normal.
But why is that causing a crash for you?
Perhaps, you could debug after it crashes.
|
|
|
|
|
kindly let us know,Is crash is appearing in Debug Mode or release mode!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I ran code analysis on my project.
It told me I had a memory leak.
I have a Linked List class with an Add function.
The Add function receives parameters, then it creates a node and fills it with those parameters.
I can't understand why their is a leak!
|
|
|
|
|
ok, but how do you remove items from the list ? is it done automatically by the list class destructor ?
Watched code never compiles.
|
|
|
|
|
|
This may sound like a daft couple of questions...
- Are you sure the memory leak is in your class? Try swapping it for one that you know doesn't leak like std::list and run your analysis again.
- Why on earth are you writing your own linked list? std::list will probably do as good a job in most cases.
Ash
|
|
|
|
|
Aescleal wrote: - Why on earth are you writing your own linked list?
Academia.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Hi all,
I have a problem to set correctly the color background of a CTabCtrl under Windows XP. IT work great under Vista/Seven. But XP still not working after many try.
So you can see 2 print screen (one in Vista and one in XP) you will see that the one on XP don't paint correctly the background windows (right beside the last tab).
http://www.devntic.com/IMAGES/PrintSreenVista.jpg[^]
http://www.devntic.com/IMAGES/printscreenXP.JPG[^]
this is my code to do what you see in these print screen..
I have a Class to manage CTabCtrl --> in this case COnglet (it's Tab in french)
BOOL COnglet::OnEraseBkgnd(CDC* pDC)
{
RECT rect;
this->GetWindowRect(&rect);
::FillRect(pDC->GetSafeHdc(), &rect, static_cast<HBRUSH>(((CDlg_Modele*)m_TabOnglet[0]->ptrEcran)->m_DlgBGColor));
return FALSE;
}
void COnglet::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CRect rect = lpDrawItemStruct->rcItem;
rect.top += ::GetSystemMetrics(SM_CYEDGE);
....
...
pDC->SetBkMode(TRANSPARENT);
pDC->FillSolidRect(rect, ((CDlg_Modele*)m_TabOnglet[0]->ptrEcran)->m_bgColor);
...
...
pDC->RestoreDC(nSavedDC);
}
Thanks in advance for any help you could provide to me
regard Etienne
PS: sorry, my english is not perfect.
modified on Wednesday, July 21, 2010 3:18 PM
|
|
|
|
|
I gave the class an English sounding name, et voilà
BOOL CMyTabCtrl::OnEraseBkgnd(CDC* pDC)
{
RECT rect;
this->GetWindowRect(&rect);
ScreenToClient(&rect);
::FillRect(pDC->GetSafeHdc(), &rect, static_cast<HBRUSH>(((CDlg_Modele*)m_TabOnglet[0]->ptrEcran)->m_DlgBGColor));
return FALSE;
}
I strongly suggest that you give identifiers English names, unless a customer demands another language in a contract. And even then, try to convince him before accepting.
A simple thing as asking for help might reduce your chances of getting a good response. But there are better reasons, working with developers from different countries being one. Going public with parts of your code being another. I once had an interface file for a complex system completely in Dutch in my hands. Oh my oh my...
|
|
|
|
|
Was it Dutch, Dutch++ or maybe Dutch#?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I'm glad you see the problem
|
|
|
|
|
Thanks for your reply and your advice.
I added the line of code that you suggested but it seems not to be working anyway in windows XP (Tested on Windows XP sp3).
To see whitch area i painted In OnEraseBkgnd, i changed the color and in Vista all seems to be in good place like you can see on this printscreen
http://www.devntic.com/IMAGES/VistaGreen.jpg[^]
but in XP i didn't see anything changing.
So what's wrong With XP and CTabCtrl?
Thanks again.
|
|
|
|
|
Hi,
Im having a LPSTR variable.I want to copy a string to this variable. The application is getting crashed while copying this string.I want to catch this exception.I have used exception class,but its not capturing that one.Please suggest me to do this.Im using the following code.
LPSTR lpszstr;
try
{
wsprintf(lpszstr,"%s","sdfsdfsd fsdfsdfsdf");
}
catch (CException *why)
{
::MessageBox(NULL,"test123","test",MB_OK);
}
Thanks,
|
|
|
|
|
People on these forums seem a bit obsessed by exceptions...
- wsprintf is a windows API function. Windows API function have a C interface, not a C++ one. As C compilers don't understand C++ exception handling Windows API functions don't throw C++ exceptions. Therefore whatever wsprintf does it won't throw, ever.
- CException is an MFC class. The only thing that throws exceptions based on CException is MFC and clients of MFC. Even if the previous point didn't apply then wsprintf couldn't throw a CException.
- IF wsprintf threw a CException derived class you're still using it wrong. MFC (due to it's long history of working on brain damaged compilers) throws exceptions by pointer and not by value. When you catch an MFC exception AND handle it you have to delete the exception afterwards. Not generally using the delete operator either. Have a look at the docs for details.
- finally even if wsprintf threw what you want it to catching it would be a bad idea. You've got code that's writing to a random area of memory. Do you really expect to be able to scribble over your process address space and get away with it? Sometimes you might be able to recover and keep going, hopefully most of the time your code will crash in a heap.
So:
- stop obsessing about exceptions but if you can't stop learn the difference between a processor exception, an operating system exception and a C++ exception
- stop mucking about with low level stuff. Don't use array of characters use vectors or strings. Don't think they're something advanced - it's the stuff you're doing (pointers and arrays and not knowing the differences between them, using C functions like sprintf when stringstreams do in a far safer manner) that's advanced
Ash
|
|
|
|
|
In addition to what Ash said, note that:
- LPSTR is a pointer to a multi-byte string (i.e.
char * ), but you are using wsprintf which is an unicode function (i.e. it works on wchar_t ) - when used with
wsprintf , the format string "%s" stand for an unicode string, but you are passing a multi-byte string instead: probably this is the reason of the crashes you are experiencing. Replace wsprintf with sprintf - to avoid problems with buffer overrun improved versions of
sprintf and wsprintf are privided: think using printf_s and wsprintf_s
|
|
|
|