|
For some reason every time I call ShowWindow it just hangs and I never get control of my application back. This didn't happen just earlier today, I may have changed something, but I have it called in two places. I know that one of them (the first example) didn't get changed, so I know that it can't be what I changed.
Here is the code that (I have changed) calls ShowWindow:
bool BuildWindow()
{
const LPCSTR pstrTitle = "Game";
const LPCSTR pstrCaption = "Game";
WNDCLASS pwdcWndSpec =
{
CS_HREDRAW | CS_VREDRAW,
WindowProc,
0,
0,
GetModuleHandle(NULL),
NULL,
NULL,
NULL,
NULL,
pstrTitle
};
if ( !RegisterClass( &pwdcWndSpec ) )
{
Console::WriteLine("Error: Unable to register window.");
return false;
}
mhwdWndHandle = CreateWindowEx(
WS_EX_TOPMOST,
pstrTitle,
pstrCaption,
WS_POPUP,
0,
0,
GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN),
NULL,
NULL,
pwdcWndSpec.hInstance,
NULL );
if ( !mhwdWndHandle )
{
Console::WriteLine("Error: Unable to create window.");
return false;
}
mhinWndInstance = pwdcWndSpec.hInstance;
ShowWindow( mhwdWndHandle, SW_SHOWNORMAL );
UpdateWindow( mhwdWndHandle );
SetFocus( mhwdWndHandle );
return true;
}
mhwdWndHandle - Global HWND
mhinWndInstance - Global hInstance
The other place I have it called is in a class I made to give better control of the console window (I have not changed):
void AdvancedConsole::SetWndState( enuWndState venuWndState )
{
ShowWindow( mhwdWndHandle, venuWndState );
}
mhwdWndHandle - Class level HWND
enuWndState - Enumeration:
__value enum enuWndState
{
wsHidden = SW_HIDE,
wsMax = SW_SHOWMAXIMIZED,
wsMin = SW_SHOWMINIMIZED,
wsNormal = SW_SHOWNORMAL
};
Any help would be greatly appreciated.
|
|
|
|
|
Just out of curiousity are you doing anything in OnPaint event that would hang for certain inputs?
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I am not doing anything with on paint. This is my window's call back function though:
LRESULT CALLBACK WindowProc( HWND vhwdWndHandle, UINT vuntMsg, WPARAM vwprParam, LPARAM vlprParam )
{
Console::WriteLine("Handle message: {0}", Convert::ToString(vuntMsg));
switch ( vuntMsg )
{
case WM_KEYDOWN:
if( vwprParam == VK_ESCAPE )
{
PostQuitMessage( 0 );
return 0;
}
break;
case WM_DESTROY:
Console::WriteLine("Main window closed.");
PostQuitMessage( 0 );
return 0;
}
return DefWindowProc( vhwdWndHandle, vuntMsg, vwprParam, vlprParam );
}
I have found out that if I use a minimize action (SW_MINIMIZE, SW_SHOWMINIMIZED, or SW_SHOWMINNOACTIVE) with ShowWindow I don't have the hanging problem.
Thanks for the fast reply.
|
|
|
|
|
By looking at what the console displays after I end the process that contains the hanging ShowWindow, I find that window is trying to process the following messages non-stop:
WM_SETCURSOR
WM_NCHITTEST
Hopefully this will be of some more help.
|
|
|
|
|
can you comment this line.
Console::WriteLine("Handle message: {0}", Convert::ToString(vuntMsg));
and check wheather it works or not... otherwize there seems to be no problem.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
I just added that line to see what messages were being sent. It was doing that before I put the line in. I am new to windows programming so right now I am lost as far as this problem is concerned. I am going to try and handle the messages that it keeps passing and see if that helps. If it doesn't I don't know what I'll do.
Thanks for your help none-the-less
|
|
|
|
|
Okay, I've been struggling with this problem for the best part of a week now. If I don't find a solution soon, my PC's going for a flying lesson
I'm developing an MFC app, in VC++ 6.0 with the latest service patch applied, running on Windows NT. The program works fine in debug mode, but dies a horrible death in debug mode. "The instruction at "0x00918ec3" referenced memory at "0x00002301". The memory could not be "written".
Here's what I've tried so far...
1) Message boxes to try and pinpoint where the crash is occurring. After a bit of trial and error, the crash appears to occur sometime after a call in the application part of the code 'MyApp.cpp' : 'if (!ProcessShellCommand(cmdInfo))'. The crash occurs after this call is made, but before it returns. The last part of my own code that is called (as far as I can tell) is 'OnInitialUpdate' which is within the view. Now as far as I can see, it looks like the crash isn't happening in any of my code. No doubt it's somthing I've done, I just can't see where I did it!
2) Having drawn a blank with my usual method of release-mode debugging, I turned to google. I've read most of the debugging tutorials here on codeproject now and thought this might herald an answer, but the crash address doesn't appear to be relevent to either the program itself or any of the .dlls it loads (I used dependancy walker to have a look at what it uses). Their base addresses seem to be in the range 0x5F400000 (MFC42.dll) to 0x780C0000 (MSVCP60.dll) - nowhere near "0x00918ec3"!
Have I missed / mis-understood anything obvious? What should I try next?
I'd appreciate any suggestions you may have - thanks very much in advance!
Success is 99% failure
|
|
|
|
|
Almost certainly you are overwriting the stack somewhere before you call ProcessShellCommand. If you can't find the mistake by inspection (get someone else's eyes on it) and you don't want to invest in something like BoundsChecker or Purify, you might try a technique I've used in similar situations: Comment out suspect code until the crash goes away, then uncomment some until the crash comes back, and use a binary search to narrow down onto your mistake.
|
|
|
|
|
You are probably doing some wild write, that is, writing at memory you dont have allocated...
Any chance you are writing a single byte too much into a buffer somehwere?
When compiling a debug version there is left some extra space at the begining and end of buffers, so you might not notice it there.
Try some of the CRT debug functions, they are pretty good at tracking such things...
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]My Photos[^]
|
|
|
|
|
do you have any commandline parameters set in ide...
greatest thing is to do wot others think you cant suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Nope, no parameters are set. I think the framework creates a new document within the call though so I guess somewhere in there, I'm doing something dodgy. I'll have another look tomorrow (if I get over this stupid tummy bug!).
Success is 99% failure
|
|
|
|
|
You can do a release build with debugging information. Single stepping can be 'odd' and the debugger can get confused about variable names (sometimes they have been optimised away, for example) but being able to see the call stack etc can be invaluable.
Paul
|
|
|
|
|
hi, i have an edit box and a button add on a tab...im trying to have it where if a user press enter in the edit box it will execute the button add (call on the add function which the button is mapped to)..how can i do this?
i've tried onchar event for that dialog and it's not detecting when i type in that edit box...
one other thing, im using microsoft commondialog activex...how can i detect if the user press CANCEL or OK
thanks alot for your help
|
|
|
|
|
Set the BS_DEFPUSHBUTTON style of the button.
MSN Messenger.
prakashnadar@msn.com
"If history isn't good, just burn it." - Sidhuism.
|
|
|
|
|
Make sure that the following propertty so not set for the edit box.
ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog box’s default pushbutton. This style has no effect on a single-line edit control
I hope it helps
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
the default button is already set on and want return for the edit box is not checked, still same problem, any other suggestions? thanks
|
|
|
|
|
HI r00k13, i cant say for sure what is wrong but just try this. If it works, its gud 4 u.
When u create a dialog box in the Dialog Editor, u r provided with two default buttons -OK & CNACEL. The proerty you are asking for is also present by default. (I have checked on my system, it is there even when u make a multiline edit box in the dialog). The OK button is clicked(OnIDOK() is called) when we press the "RETURN" key.
It may be the case that you have deleted the default OK button and you have currently set a new button(that u hav created) as default. If it is so, change the ID if ur default Button from whatever it is currently, to IDOK. It may solve ur problem.
Just giv it a try. Tell me if it works.
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hello there. I am developing a simple 4-track sequencer using MFC, DirectMusic and DirectSound, under Windows 98. All is going well, however there is one thing I need my app to do and I have no idea how to do it!
To prevent playback glitches there must have be a different audio file loaded on each track (it's a one-file per track sequencer), so to stop the user being able to load the same file on different tracks I need to filter out a loaded file's entry from the Open File Dialog (I am currently using a standard CFileDialog object). How is this done?
Any help is much appreciated!
|
|
|
|
|
I reckon you'll need to write your own dialog, unless you get nasty and mark files as hidden when they are opened, and remark them when they are closed. Note, I am NOT recommending this approach. what happens to the files if the power cuts out while the program is running ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
A dialog box that I'm using as a child control is receiving windows message 0x0127. I can't find anything in the MSDN documentation on it and the Microsoft Spy++ application shows it as "unknown".
Does anybody know what this message is defined as?
The dialog contains several controls including three COM controls. The message seems to be received anytime the standard tree control processes a WM_KEYDOWN message. Operating system is WinNT 4.0 SP6.
|
|
|
|
|
Hey, u needa improvr ur search skills(dont mind!;P)
This is what i found out:
BizTalk Server 2000 Error Messages
The BizTalk Messaging Configuration object model error messages defined by BizTalk Server can be used in your application by including the bts_config_errors.h file located in the BizTalk Server installation directory at \Program Files\Microsoft BizTalk Server\SDK\Include. These error messages, returned during design time by the methods and properties of the object model, contain a BTS_ prefix in the message name. All other errors occur during run time, while BizTalk Server is processing a document.
The following table contains both design time and run time errors.
Message name
CIS_E_RECEIVING_INTERCHANGE_FAILED
Value
0x0127
Description
The specified interchange was not received.
See for urself at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/biztalks/htm/lat_sdk_errmsg_axsh.asp[^]
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
My search DID reveal the information you describe, however, we are not using BizTalk Server in house.
The message, 0x0127, is received on the message queue of my dialog. Are you familiar with BizTalk or did you just search on "0x0127" as I did? If you are familiar with BizTalk, can you explain why I would be getting a BizTalk error value in a dialog message queue when we don't have it implemented here?
I searched MSDN for "CIS_E_RECEIVING_INTERCHANGE_FAILED" and the only hits I got were the same error message lists. I searched Google for "CIS_E_RECEIVING_INTERCHANGE_FAILED" and it listed a single link to the same error message list in MSDN.
|
|
|
|
|
I am using enhanced metafiles in my MFC app to display simple, small, one colour images. The images themselves are pre-created in another drawing package. I was wondering whether it was possible to change the colour of the image prior to display on the screen....say from black to red. An example of the drawing function is given below:
code =============================================
void CSediStructure:: Draw(CDC* pDC)
{
// Get the metafile
HENHMETAFILE hemf = GetEnhMetaFile(m_sfStructureFile);
// Get a HANDLE to the device context
HDC hDC = pDC->m_hDC;
// Store the current WorldTransform structure
XFORM oldXForm;
GetWorldTransform(hDC, &oldXForm);
// Set the graphics Mode to "Advanced" so we can Transform the metafile if necessary
int nOldGraphicsMode = SetGraphicsMode(hDC, GM_ADVANCED);
// Perform any transforms (rotation)
if(m_dRotationAngle != 0)
Rotate(m_dRotationAngle, m_nAnchor, hDC);
// "Play" the metafile to the screen
PlayEnhMetaFile(hDC, hemf, m_BoundingRect);
// Free metafile resource and reset the graphics mode
DeleteEnhMetaFile(hemf);
SetWorldTransform(hDC, &oldXForm);
SetGraphicsMode(hDC, nOldGraphicsMode);
}
code =============================================
I've found the MSDN info on functions like GetEnhMetaFilePaletteEntries() but I'm not sure how it all works and whether I can actually do what I want to do.
Any help would be appreciated.
thanks
JezzerP
___________________________
Jeremy Preston
|
|
|
|
|
I am not sure what the rotate stuff is about, shouldn't that come after you play the meta file. Any way, you can use the GetPixel and set Pixel function to actualy change the colors for the pixels, since it should be in device compatible format. I know there are other ways (much faster ways) to accomplish what you want, but then things may get a bit more complicated. I recommend look at the Bitmap & Pallets section of codeproject (KeyWord: DIBSECTION).
INTP
|
|
|
|
|
Thanks John
The Rotate function goes off and calls SetWorldTransform which needs to be called before the metafile is played. I'd started to look at pallets and it looks like it's possible to get hold of pallet info for a metafile but I couldn't find any easy way to reset the data to give new colours. I'll have a look at the CodeProject stuff today
___________________________
Jeremy Preston
|
|
|
|