|
---Mark--- wrote:
But how would I in the future narrow down and single out my misspelling
When we are fixing the compilation errors, the 1st error is the most important one we have to look at. Basically the rest hundrads would probably be gone after we have fixed the first.
Regarding to the misspellings, hummm.... The only way, I guess, is to take a rest and have a cup of tea. Later you will see more clearer!
Maxwell Chen
|
|
|
|
|
|
Hello all,
I used to program Unix(C/C++) and now trying to learn program in Windows. I would appreciate if someone could kindly recommend me some resources, books, URLs, for learning Windows programming. I am espeacilly interested in system and network programming, and device driver development. These are the area I used to do when I programmed Unix.
Thank you very much.
I can be reached at vnm6@lycos.com
I am a Unix programmer and trying to learn Windows now.
Ken Ji
|
|
|
|
|
Try Programming Windows by Charles Petzold, Ms Press (C++)
Chris Maunder has a list of recommended books in one of his article. Do check on that also.
Sonork 100.41263:Anthony_Yio
Life is about experiencing ...
|
|
|
|
|
Thank you Anthony for your info.
|
|
|
|
|
Hello I was trying to debug this code (see below), because after a few minutes it crashes.
So I used a try{ }catch(...) to catch the exception but I dont know what type of exception it was. Is there a way to tell?
I tried using TRY{} CATCH_ALL() but it dod not catch anything??
try{<br />
DeleteObject(hbr);
hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br />
if (nCtlColor == CTLCOLOR_STATIC )<br />
{<br />
CWnd *Ctrl = GetDlgItem(pWnd->GetDlgCtrlID());<br />
<br />
if (Ctrl)<br />
{ <br />
CRect Rect; <br />
Ctrl->GetWindowRect(&Rect);<br />
this->ScreenToClient(&Rect);<br />
COLORREF Clr = GetDC()->GetPixel(Rect.left-1, Rect.top-1);<br />
hbr = CreateSolidBrush(Clr);<br />
ASSERT(pDC);<br />
if(!m_staticTextBgd)<br />
pDC->SetBkColor(Clr);<br />
pDC->SetTextColor(RGB(m_fntR,m_fntG,m_fntB));<br />
pDC->SetBkMode(m_staticTextBgd?OPAQUE:TRANSPARENT);<br />
}<br />
}<br />
}<br />
catch(...)<br />
{<br />
printf("Error");<br />
}<br />
I tried catching CResourceException and CMemoryException and many others but it did not catch anything?
How do I know what exception is being thrown?
---
|
|
|
|
|
Try catching a CException, that might work. If it does get the error message and it might help you figure out what type of exception is being thrown.
- Aaron
|
|
|
|
|
First thing I tried, it seems it does not throw a CException at all.
I am sure it is a memory resource overflow problem, even though I am deleting my HBRUSH object.
---
|
|
|
|
|
Appart from not knowing how to get infomation from an unknown exception, I have fixed my code problem.
COLORREF Clr = GetDC()->GetPixel(Rect.left-1, Rect.top-1);
This line does not like being called so often.(why??) So I just set Clr to the background color as it actually does not change after initilising it.
Clr = RGB(m_bkR, m_bkG, m_bkB);
cheers
---
|
|
|
|
|
There are a limited number of device contexts available at any one time. Every time this executes, you are locking one of these DCs with GetDC() but not releasing it with ReleaseDC() . Eventually, there will be no DCs available, and GetDC() will return NULL . Since you're not doing any error checking, you'll get a NULL-pointer exception while trying to call GetPixel() .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Two questions:
One, can interface methods have default parameters? i.e.
HRESULT MyMethod ([in] int size = 0) Two, can a class that implements and interface have a constructor with paramaters?
Thanks!
- Aaron
|
|
|
|
|
hi
One - Yes, An interface method can have parameters with default values provided the parameter shud be optional too. The parameter settings while creating the function defenition in IDL is as fllows:
[in] short i, [in] short j, [in, out, optional, defaultvalue(117)] short* k, [out, retval] short* l
and the c++ function signature will be:
STDMETHODIMP MyClass::Test(short i, short j, short *k, short *l)
Two - A class that implimets an interface can have constructor with parameters. But no way to use that . If you use CoCreateInstance to create the client then we can't use the c++ class name directly and so cunstructor parameter also. Only way where we can use the c++ class name to create the com class is CComObject<MyClass> . But even this CComObject does not accept constructor initializers.
rgds...mil10
|
|
|
|
|
In a support library I'm developing which is serving as the foundation of an application I'm working on, I've provided a whole bunch of augmented debug functionality. For example, if I hit an assert, the replacement assert implementation logs this sort of thing to a file and to OutputDebugString:
---- ASSERT LOG OPENED ----
Version 0.7.4.1
assertion failure 5/12/04, 16:49:42.353738
File: btlocalclient.cpp
Line: 1086
Expression: Unrecognized command in BTLocalClient_t::AsynchMessageReceived
Call stack: 0x00417B93 (BTLocalClient_t::AsynchMessageReceived +0x542, btlocalclient.cpp line 1086)
0x004F15D1 (AsynchMessageTrigger_t::Triggered +0x60, asynchmessagetrigger.cpp line 93)
0x004F6E88 (EventServer_t::ThreadFunction +0x387, eventserver.cpp line 284)
0x0042F8BF (BTServer_t::ThreadFunction +0x2E, btserver.cpp line 93)
0x004F6A01 (EventServer_t::ThreadFunctionEntryPoint +0x70, eventserver.cpp line 174)
0x1020BFD2 (UNKNOWN)
0x7C57B382 (UNKNOWN)
I'm providing that detail so no one asks "why are you replacing assert" - the utility should be clear and MS should have done a better job of providing this sort of info.
Anyway... One part of this support library is an EventServer object running in a thread, servicing EventTrigger objects by WaitForMultipleObjects - EventTriggers have an associated triggler HANDLE of one kind or another - could be an event, could be a TCP/IP socket, could be a device handle doing asynchronous I/O, that sort of thing. The server thread is servicing a remote client server and device objects controlling Bluetooth ASICs. An EventServer running at critical priority is a necessary part of the application I'm working on. Anyway every once in a while during the development process I introduce a bug where the code gets stuck in a loop. At critical priority, that brings my system to its knees and depending on how bad it is, I can't get over to Visual Studio to hit the pause button on the debugger. So I just added a feature to the event server where, optionally, another thread watches it and if the event server stops punching a watchdog (to borrow a metaphor from hardware engineering) then the watcher thread suspends the event server and pops up a dialog indicating that the event server stalled, abort retry ignore, all that.
I caught the case where the event server has hit an assert and is therefore legitimately not punching the watchdog...assert puts the watchdog to sleep. But what if I set a breakpoint? Once I start stepping through code, the watcher thread fires almost immediately.
What I wanted to do was catch EXCEPTION_BREAKPOINT and put the watchdog to sleep in that situation. I already have a __try exception handler so that address exceptions for example get turned into asserts and log the info shown up above, the call stack and everything. I augmented it as follows:
int
ExceptionFilter( unsigned int code, struct _EXCEPTION_POINTERS *ep )
{
g_exception_context = ep->ContextRecord;
if(code == EXCEPTION_ACCESS_VIOLATION)
release_error("Access violation");
else if(code == EXCEPTION_INT_DIVIDE_BY_ZERO)
release_error("Integer divide by zero");
else if(code == EXCEPTION_PRIV_INSTRUCTION)
release_error("Privileged instruction");
else if(code == EXCEPTION_ILLEGAL_INSTRUCTION)
release_error("Illegal instruction");
else if(code == EXCEPTION_NONCONTINUABLE_EXCEPTION)
release_error("Noncontinuable exception");
else if(code == EXCEPTION_GUARD_PAGE)
release_error("Guard page violation");
ADD else if(code == EXCEPTION_BREAKPOINT)
ADD {
ADD debug_printf("Why isn't this working???\n");
ADD EventServer_t::PauseCurrentThreadStallWatcher();
ADD }
g_exception_context = NULL;
return EXCEPTION_CONTINUE_SEARCH;
}
But it didn't work...EXCEPTION_BREAKPOINT isn't raised, or at least isn't able to be caught using __try.
Does anyone know what EXCEPTION_BREAKPOINT is for, will it work for what I'm trying to do if I do something a bit different?
Alternatively, does anyone know of a way that the watcher thread can determine whether the debugger has been active recently, like having just set a breakpoint and released the debuggee to do a "step out of function"? IsDebuggerPresent() isn't good enough because that returns TRUE whenever I'm in the debugger, that says nothing as to whether I'm stepping through code.
Thanks,
Brian
|
|
|
|
|
Breakpoint exceptions are not raised when the debugger is single-stepping. Try checking for EXCEPTION_SINGLE_STEP instead. If that doesn't work, I'm as stumped as you are...
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Just a quick question...is it possible to use these two libraries in VC6 or do you have to have VS.NET in order to use them. Thanks.
- Aaron
|
|
|
|
|
|
|
Greetings,
I'm trying to display simple debug messages from the constructor and destructor of a class (we'll call it MyClass.) I have a simple CDialog based project and if I declare a member object of MyClass in the main dialog class definition, I expect to see the "MyClass::MyClass()" message box when starting the app and the "MyClass::~MyClass()" when closing the app. The destructor message is never displayed. I've used ::MessageBox() and AfxMessageBox() and I've tried NULL and ::GetDesktopWindow() as the hWnd param to ::MessageBox.
Of course, if I just locally create and destroy the object in a function body (such as a button click event), then I see both messages.
Can anyone clue me in as to why this is happening? Does it have something to do with the fact that the main dialog has already been destroyed when the member MyClass object's destructor is called?
Thanks,
Justin
|
|
|
|
|
If this is an MFC app, make sure you don't have the line
m_pMainWnd = &dlg
in CYouWinApp::InitInstance.
|
|
|
|
|
Thanks. That was the problem. Does that work because the main dialog isn't really the main window, so if you set m_pMainWnd to the dialog, when you kill the dialog, the app prematurely teminates? (I read the MSDN docs, but I'm not totally clear on it yet.)
Thanks,
Justin
|
|
|
|
|
Er well it works because of the way DoModal works. Each (UI) thread has a message pump as im sure u know, and in MFC, that pump is usually started by returing true from InitInstance. When you call DoModal on a dialog - you want that call to block until the dialog is closed - and you also want to continue to pump messages while waiting. MFC does that by running another message pump within DoModal, that runs until EndDialog is called and then passes control back out to the "outer" pump. That all apples if your not using a dialog for you "main" window.
When the message pump in DoModal comes across a WM_QUIT message, it handles it differently. Its the outer pump that must process this quit message, so it reposts another WM_QUIT message and then exits it's loop. If you have m_pMainWnd set to anything other than NULL, then the WM_QUIT message is reposted.
Once a thread has received WM_QUIT, calling GetMessage/PeekMessage will do nothing. Internally, a MessageBox also pumps and process messages - so if you have a non-null m_pMainWnd, your message box will start it's own message pump, and will get the WM_QUIT message which was reposted - and exit.
If you set m_pMainWnd to NULL, the WM_QUIT message is esentially swollowd by the message pump in DoModal - even though the DoModal loop exits, the WM_QUIT doesn't get reposted, and hence the message box doesn't pick it up. The app is then exited via returing false at the end of InitInstance.
|
|
|
|
|
Hi-
I have some source code (samples) that will be distributed with an API. I'd like the samples to be in source control of course, but I'm not sure the proper way to remove source control for distribution. (So customers don't get a message like: "This project appears to be under source control, but ...")
Can this process be easily automated with an installer such as Nullsoft's NSIS? It should be clear, but I don't want to remove source control entirely, just for the distributed code.
|
|
|
|
|
Hello, i hope you can help me,
Ik need a program for instance a .exe file that when it runs it holds the image of my entire screen, meanwhile a other program is changing information and it had to fade into the current screen total time +/- 1 sec and then the program closes again. Is this possible? if yes please tell me how i can make this. I am not a verry good programer in c++ or maybee you can help me with it.
Thanks Johan
|
|
|
|
|
If you're using W98 or above, there is an AlphaBlend function that you can use to make your image fade.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi
I made a class that it's header does not include any other files..
however, when i used MAX_PATH (defined in windef.h ) it compiled well.
how that comes ? shouldn't i include windef.h or a file that includes it to use MAX_PATH ?
(others classes include stdafx.h but this one doesn't)
also how can I make such a (global #define ) ?
|
|
|
|
|