|
Thanks to all that helped me get over my debug issues...
It turns out (as many suggested) that the code I was porting from 'c' and wrapping in an MFC gui had to lose all the old malloc/reallocs it had to work correctly without causing debug to puke. This manifested itself in strings for the most part.
From what several said, malloc uses a different stack than new, and was causing one to stomp on the other.
I must ask at this point...why? Is there a "safe" wrapper out there for malloc (to possibly save re-writing old code)? why did only debug have a problem with sharing methods? Based on call stacks examined while getting to the bottom of this, I saw CString using malloc and free deep down inside... why don't these cause issues?
Thanks again
|
|
|
|
|
new and delete call malloc/free internally, I believe, but if you're writing C++, the rule is to use new/delete. Apart from anything else, it gives you constructor/destructor behaviour.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The key is if you use malloc /realloc to allocate memory you use free to deallocate the memory.
If you use new to allocate memory you use delete to deallocate it.
When I port code from C, I don't bother changing the malloc's. There's no point and it often causes more bugs than just leaving the mallocs/frees alone.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
It may not be the problem of my own procedure, because no matter what new projects I create, I got those 15 errors.
who can copy his winuser.h file and send to me? I am using VC6.0++
Thanks a lot!
my email: linq@kth.se
|
|
|
|
|
what is it with newbies thinking a copy and paste will solve all their problems. use #include <windows.h> instead.
|
|
|
|
|
Did you search on internet maybe you can find this file
|
|
|
|
|
I'm using Visual Studio 2005 and I wrote a DLL program in C. I want to add a status window to this DLL that creates a window and dynamically updates labels each time the DLL is called. What is the best and easiest way to do this? Should I use C++ and Windows Forms or use MFC?
|
|
|
|
|
mparent wrote: Should I use C++ and Windows Forms or use MFC?
You'd be using C++ in both instances.
The real question is, what sort of dll is it ? Is it using MFC ? Is it managed ? I'd go with whatever approach doesn't add a dependancy to the dll.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
I have some problems using a scrollbar control (MFC), I have derived a class form CScrollbar and used it in my Dialog class.
m_scrollHor.Create(SBS_HORZ | WS_CHILD, CRect(100,400,300,430),this, 4712);<br />
m_scrollHor.ShowWindow(SW_SHOW);
the problem is, that the handler for HScroll Event is never called...
i just added the function and set a breakpoint there but nothing happens...
void CScrollBarGrid::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)<br />
{<br />
<br />
CScrollBar::OnHScroll(nSBCode, nPos, pScrollBar);<br />
}
i have also written a function to handle a mouse click and this works fine.
Any hints for me?
Thanks!
|
|
|
|
|
are you getting the HScroll message in the dialog that is the parent of the scroll bar?
cje
|
|
|
|
|
|
Is it at all possible to capture an image of what lies beneath a window? Without making it obvious to the user (ie by minimizing first). I'm implementing a fade-in/fade-out for a window which must work on win95 upwards. My method is to capture the desktop and blend this bitmap with my own window. This works for a fade-in when the image can be captured before the window is created, but not for a fade-out where the initial image may have changed.
The only method I can think of is by constantly monitoring the windows state. But this is going to be difficult and a not to mention a system hog.
|
|
|
|
|
You can't capture a bitmap that does not exist.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The way I see it, it does exist, just not on the screen. But, I guess I'm asking to do the impossible again.
|
|
|
|
|
I've never actually used it myself, but the WM_PRINT and WM_PRINTCLIENT messages are supposed to do this. The trick is the window in question has to handle those messages.
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
Hi,
I am working on a object based graphic editor that's implemented using CView class. I am thinking of adding a text object where user can edit the text directly on screen. It will function like the text tool in MSPaint. Any one has any idea on how to implement this?
Thanks
Chun
|
|
|
|
|
the easiest way is to just show a small edit control at the place where you want to edit the text, then hide it when you're done - a bit like what Explorer does when you want to change a filename.
|
|
|
|
|
Hello.
I am new to DLL programming but I do know the basics (injection, creation).
Lets say I make a windows application in MS VS.Net 2003. The application just contains a simple textbox.
Now, how would i access this textbox from my dll? I want to change for example the textbox backcolor. Do I need to know the textbox name to do this? Or maybe this is impossible?
Thx in advance
|
|
|
|
|
Through the WM_DRAWITEM message I can get to the DRAWITEMSTRUCT hence it’s hdc member provides a handle to a device context. Then, having access to device context what function or procedure if any could lead me to the lpString Parameter of an ExtTextOut function that holds the Pointer to a string that specifies the text to be drawn in a List View Control?
p.s.
bearing in mind that since, ExtTextOut offers a handle to the device text then the reverse should also be true or NOT?
|
|
|
|
|
NOT, you can't give something to a function then later ask for it back. You should make a copy of the string the first time you use it. After sending it to the ExtTextOut, it is no longer a string, but a collection of pixels in the DC.
|
|
|
|
|
Hi,
I am successfully using the PropertySheet() function with the PSH_WIZARD97 flag. All is working fine.
But when i try to set the Next/Prev/Finish/Cancel/Help buttons to ownerdraw then it does not work!
To clarify: I successfully set those buttons to ownerdraw state when using not the Wizard97 flag - means when using a normal property sheet.
But when defining the PSH_WIZARD97 flag the buttons are not ownerdrawn anymore.
However, i still can change the size and the labels of those buttons.
How/when i am doing this: I am using the callback function and on PSCB_INITIALIZED i am accessing those buttons:
For example, to set another text for the Help button i do the following:
SendMessage(GetDlgItem(hDlg, IDHELP), WM_SETTEXT, NULL, (LPARAM)(LPTSTR)szNewLabel);
But when setting the ownerdrawn flag, it seems to either get ignored or overwritten. I do it the following way:
DWORD dwStyle = BS_OWNERDRAW|WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN;
SetWindowLong(GetDlgItem(hDlg, IDHELP), GWL_STYLE, dwStyle);
Again - if i remove the PSD_WIZARD97 flag, then the button is ownerdrawn... but then i have a normal property sheet and i want that wizard interface.
Does anybody know a solution?
Thank you
Nikolaus
|
|
|
|
|
Hi!
I use completion port for asynchronous communication over named port. The one program sends to named port only one type of messages. The other program has 3 threads which each gets 5 asynchronous requests from named port (using completion port). Then each thread gets one message through GetQueuedCompletionStatus, compute it, reply to that message to the named port and make another request.
The programs communicate for some time, and suddenly GetQueuedCompletionStatus returns error 998 (ERROR_NOACCESS). When there is one thread everything seems to be ok. Any idea what could be wrong? What could be the reason of such an error?
Waiting for any idea
Gosia
|
|
|
|
|
what do the first few lines of "winuser.h" look like ?
|
|
|
|
|
me think it's some typo in one of his .h file that gets propagated to other files.
|
|
|
|
|
for example from: http://www.cs.umbc.edu/~squire/download/WinUser.h
/****************************************************************************
* *
* winuser.h -- USER procedure declarations, constant definitions and macros *
* *
* Copyright (c) Microsoft Corporation. All rights reserved. *
* *
****************************************************************************/
#ifndef _WINUSER_
#define _WINUSER_
//
// Define API decoration for direct importing of DLL references.
//
#if !defined(_USER32_)
#define WINUSERAPI DECLSPEC_IMPORT
#else
#define WINUSERAPI
#endif
#ifdef _MAC
#include <macwin32.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef WINVER
#define WINVER 0x0500 /* version 5.0 */
#endif /* !WINVER */
#include <stdarg.h>
#ifndef NOUSER
typedef HANDLE HDWP;
typedef VOID MENUTEMPLATEA;
typedef VOID MENUTEMPLATEW;
#ifdef UNICODE
typedef MENUTEMPLATEW MENUTEMPLATE;
#else
typedef MENUTEMPLATEA MENUTEMPLATE;
#endif // UNICODE
...
....
.....
|
|
|
|