Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
S

Skarrin

@Skarrin
About
Posts
7
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Self-registered edit control class crashes because of wrong GetWindowTextLength return value
    S Skarrin

    The control does not use unicode, I have checked that. As I wrote, the problem only occurs if I enable XP visual styles and themes for the application by including a manifest file in the executables directory. I already tried to write replacements for Get/SetWindowText: void CGXEditControl::GetWindowText(CString& s) { if (IsThemeActive()) { const int nLen = ::GetWindowTextLengthW(m_hWnd); CStringW sW; ::GetWindowTextW(m_hWnd, sW.GetBufferSetLength(nLen), nLen+1); sW.ReleaseBuffer(); s = sW; } else { //CGXEditControl is derived from CEdit, CGXStatic CEdit::GetWindowText(s); } } void CGXEditControl::SetWindowText(const CString& s) { if (IsThemeActive()) { CStringW sW(s); ::SetWindowTextW(GetSafeHwnd(), sW); } else { CEdit::SetWindowText(s); } } This prevents the heap corruption, but then the edit control contains a lot of unreadable stuff like arabic letters :omg: even though the debugger shows that sW seems to contain a correct string like "1120". The problem seems to be the registration process of the class GXEDIT. In CGXEditControl::CreateControl, if I replace the class name "GXEDIT" with the standard "edit" class in the call to CEdit::Create, everything works! But I don't know what side effects this will have for the rest of the library :confused:, so I want to avoid this workaround if possible. BTW, this library is a very antique version of Stingray's Objective Grid, dated 1997 :-O . Regards, Jens

    C / C++ / MFC css performance help question

  • Self-registered edit control class crashes because of wrong GetWindowTextLength return value
    S Skarrin

    Part of this third-party library is a grid control, and the problems occurs when a GXEDIT control is created in-place to edit the contents of a cell. The cell contains a 4-digit number, and the value returned by GetWindowTextLength is 12. But only if I discard this value and reserve 25 bytes or more in CString::GetBufferSetLength, the heap doesn't get corrupted. It's strange, but I think this is only a side effect of some error in the class registration. If I don't use the XP visual styles for this app (no manifest file), everything works fine. Other edit controls that are of the systems standard "edit" class type, work ok with or without styles enabled... Regards, Jens

    C / C++ / MFC css performance help question

  • Self-registered edit control class crashes because of wrong GetWindowTextLength return value
    S Skarrin

    Hello, long title, short story: a rather old third-party library uses the following code to register its own edit control class: static const TCHAR BASED_CODE szEdit[] = _T("GXEDIT"); WNDCLASS wcls; // check to see if class already registered if (!::GetClassInfo(hResource, szEdit, &wcls)) { // Use standard "edit" control as a template. VERIFY(::GetClassInfo(NULL, _T("edit"), &wcls)); // set new values wcls.style |= GX_GLOBALCLASS; wcls.hInstance = hResource; wcls.lpszClassName = szEdit; AfxRegisterClass(&wcls); This works fine unless XP themes are enabled. If they are and I use GetWindowText(CString-variable) with this edit control, the CString destructor causes a heap corruption because ::GetWindowTextLength reports less bytes than ::GetWindowText actually receives, and thus CString::GetBufferSetLength allocates not enough memory. Is there a simple solution to change the above code so that this GXEDIT works with XP themes? I already tried rewriting it using WNDCLASSEX instead, but that didn't help. adTHANKSvance, Jens

    C / C++ / MFC css performance help question

  • Problem converting project from VC6 to VC8
    S Skarrin

    Christian Graus wrote:

    I thought CArray always had two args ? I guess it's too late to convert this code to standard C++, but for future reference, using the standard containers ( such as vector ), would insulate you from these sort of issues.

    The code snippets I posted are all located in Microsofts very own header files :rolleyes:. The cgraph.cpp file which causes the error does not use any template classes itself, it just includes afximpl.h because it calls other functions like AfxGetFileTitle defined there. (In case anyone knows it, the subproject making trouble is an old commercial product called "Graphics Server 5" from "Bits Per Second Ltd.", which we last upgraded before 2000 :-O ). Regards, Skarrin

    C / C++ / MFC help c++ question csharp visual-studio

  • Problem converting project from VC6 to VC8
    S Skarrin

    Hello, in a subproject,while compiling a cpp file which includes afximpl.h, I'm getting the following error message: c:\Programme\Microsoft Visual Studio 8\VC\atlmfc\include\..\\src\\mfc\\afximpl.h(734) : error C2976: 'CArray' : too few template arguments The error is caused by a class CVariantBoolConverter, also in afximpl.h: class CVariantBoolConverter { protected: CArray'<'CVariantBoolPair> m_boolArgs; public: ... As CArray is forward declared in afx.h as template'<'class TYPE, class ARG_TYPE> class CArray; C2976 occurs because of the missing ARG_TYPE argument in the CVariantBoolConverter declaration. So far so good... but when I dig deeper to the original declaration of CArray in afxtempl.h: template'<'class TYPE, class ARG_TYPE = const TYPE&> class CArray : public CObject { public: // Construction CArray(); ... ARG_TYPE is suddenly optional! This is clearly a mismatch between the forward and real declaration of CArray, but the question is why am I the only one wich seems to be having problems with this bug? We already have successfully converted other projects using templates without errors in my company, and I can't find anyone via Google or Usenet who is having the same or a similar problem. Since I'm completely :confused: and X| now I hope someone can shed a ray of light on this... adTHANKSvance, Skarrin

    C / C++ / MFC help c++ question csharp visual-studio

  • CComboBox and Loading directories
    S Skarrin

    You must not give a constant string as path spec :mad:: " lpPathSpec Points to a null-terminated string that contains the path or filename. DlgDirListComboBox modifies this string, which should be long enough to contain the modifications. For more information, see the following “Remarks” section. " HTH, Jens

    C / C++ / MFC help

  • Developer's desktop wallpaper
    S Skarrin

    Nudity? Thats way too much real life :-O ! Of course, the only wallpapers that fit for a developer are computer generated pictures ;) Have a look at these sites: http://www.irtc.org http://www.digitalblasphemy.com (great links page!) http://www.cognitivedistortion.com http://www.visualparadox.com http://www.nightprowler.de I already have so many of them that I had to install a tool that changes my wallpaper every 15 minutes :rolleyes: Jens

    The Lounge com question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups