|
The information being reported here is merely showing memory being reallocated as a string is manipulated and its size increased. The actual tidy up of reallocated and deallocated blocks will happen elsewhere, when the string destructor is called. Remember that tools like this are only pointing you to areas of your code that could be potential problems, it is up to you to verify whether they are real problems or not.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks for the tip 
|
|
|
|
|
Hi,
I want to use an unregistered tlb file. To achieve this I figured out that i will need to install the tlb file in WinSxS folder.
Now my problem is how do i create a manifest file with this tlb file. Mt.exe requires -dll option to be used if -tlb file is specified to it.
Can anyone please help me out
|
|
|
|
|
|
I have some third party code that has stopped working since I moved to VS2010.
A popup color picker now no longer pops up from it's source button. Ultimately, its CWnd::CreateEx call fails (technically the call to AfxCtxCreateWindowEx). GetLastError says 0x00000579 (Invalid menu handle). It doesn't have a menu.
The same code works in VS6.
Any suggestions?
My CREATESTRUCT in CWnd::CreateEx looks like this:
<edit -="" get="" the="" right="" one="" this="" time!="">
lpCreateParams 0x00000000 void *
hInstance 0x00400000 {unused=9460301 } HINSTANCE__ *
hMenu 0x00000000 {unused=??? } HMENU__ *
hwndParent 0x008a06be {unused=0 } HWND__ *
cy 294 int
cx 278 int
y 673 int
x 571 int
style -771751935 long
lpszName 0x00000000 <Bad Ptr> const char *
lpszClass 0x00168828 "Afx:00400000:800" const char *
dwExStyle 0 unsigned long
modified 24-Oct-11 17:58pm.
|
|
|
|
|
I see a menu handle in the above, but this may not be valid for some combinations of Window styles.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
You're right - I edited to put the right one in!
|
|
|
|
|
style -771751935
style 0xD2000001
and includes both WS_CHILD and WS_POPUP , which is an illegal combination according to the documentation[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks Richard - that is a good lead! In the meantime I found that the invalid menu handle message was coming from PreCreateWindow.
This is because:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\SRC\WINCORE.CPP
BOOL CWnd::PreCreateWindow(CREATESTRUCT& cs)
{
if (cs.lpszClass == NULL)
{
VERIFY(AfxDeferRegisterClass(AFX_WND_REG));
ASSERT(cs.style & WS_CHILD);
cs.lpszClass = _afxWnd;
}
return TRUE;
}
but
C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\wincore.cpp
BOOL CWnd::PreCreateWindow(CREATESTRUCT& cs)
{
if (cs.lpszClass == NULL)
{
VERIFY(AfxDeferRegisterClass(AFX_WND_REG));
ASSERT(cs.style & WS_CHILD);
cs.lpszClass = _afxWnd;
}
if ((cs.hMenu == NULL) && (cs.style & WS_CHILD))
{
cs.hMenu = (HMENU)(UINT_PTR)this;
}
return TRUE;
}
|
|
|
|
|
Good catch, don't you just love MFC!
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This turned out to be the problem, cheers!
[third party....grrr... mumble mumble]
|
|
|
|
|
Hi all, do you know how to add a ActiveX control to a WTL main frame? I searched quite a lot and it seems all samples are using a dialog inheriting CAxDialogImpl while I do not want to use dialogs. Is it possible to host ActiveX control directly from main frame (which inherits from CFrameWindowImpl)?
Thanks in advance.
Wei
|
|
|
|
|
If you don't want a dialog what about using a View derived from CWindowImpl to host the ActiveX control?
|
|
|
|
|
Come to think of it I seem to remember ATL or WTL has window templates designed to host ActiveX controls. I think there's an example on the net that designs and implements a 'Bullseye' ActiveX control.
|
|
|
|
|
Hello.
I'm porting a *nix C code to Windows using MingW.
Having trouble with syslog.h.
Is there any syslog.h analog in Windows so that I could include the headers like:
#ifdef WIN32
#include <windows header>
#else
#include <syslog.h>
#endif
?
Thank you.
|
|
|
|
|
Here[^] are some possible suggestions.
|
|
|
|
|
|
locale loc("chs");
mbstate_t mystate;
char origin[] = "追求追求";
wchar_t dest[9] = { 0 };
const char * pc;
wchar_t * pwc;
const codecvt<wchar_t,char,mbstate_t>& myfacet =
use_facet<codecvt<wchar_t,char,mbstate_t> >(loc);
codecvt<>.in() translates char into wchar_t characters, but the first letter of origin[] is always translated wrong,the remaining characters are fine.
could someone help me out?
|
|
|
|
|
Cold_Fearing_Bird wrote: char origin[] = "追求追求";
You are trying to set a unicode/wide string to ANSI buffer.
|
|
|
|
|
|
I have tried the line of code that you complain about, but it compiles successfully. Please try and be more clear about your problem.
|
|
|
|
|
Yes,Thank you.i debug in detail this time. I know where is wrong . i know what caused this problerm.
thank you again.
|
|
|
|
|
Please don't delete your messages; if you find the answer yourself then post the information so others may benefit from it.
|
|
|
|
|
I want to write a REG_MULTI_SZ value (e.g 100-104) in registry. My code is like
<pre lang="c++">HKEY objHKey;
CString strReturn;
CString subkey("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters");
// Open Registry key for Vlc Path
if( RegOpenKey( HKEY_LOCAL_MACHINE,
(LPCTSTR)subkey, // what to open
&objHKey // on success, handle goes here
) == ERROR_SUCCESS )
{
unsigned char * format = new unsigned char [100];
unsigned char p1[5] = "998";
unsigned char p2[5] = "999";
sprintf((char*)format, "%s\\0%s\\0\\0", p1, p2);
int ILenght = 20;//strlen(format);
unsigned char *ptr= (unsigned char *) strTemp.GetBuffer(0);
if(ERROR_SUCCESS != RegSetValueEx(objHKey,
_T("ReservedPorts"),
NULL,
REG_MULTI_SZ,
//(BYTE*)_T("1000-1004"),
ptr,
strTemp.GetLength()))
{
AfxMessageBox(_T("Failed to update in registry."));
}
// Close the registry
RegCloseKey( objHKey );
}</pre>
But this is not updating in registry.
|
|
|
|
|
sprintf((char*)format, "%s\\0%s\\0\\0", p1, p2);
The result of the above command will produce the string:
998\0999\0\0
which is obviously not what you want; the format string should be "%s\0%s\0\0" .
You also say that this is not updating in registry; do you get the error message or see some other problem? Are you running this code with administrator privileges and have you opened your registry key with the correct permissions for updating values?
|
|
|
|