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
E

Ernesto D

@Ernesto D
About
Posts
83
Topics
27
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Serializing objects using XLM
    E Ernesto D

    boost looks VERY interesting, i think ill go with it. Thanks!

    ATL / WTL / STL c++ question com xml

  • Serializing objects using XLM
    E Ernesto D

    thanks for your answers, to be honest, i dont wanna include COM simply because i dont know how to use it (blushes). I dont know about interfaces and that stuff. But lets say that the only thing off-limits would be MFC (COM is OK), which parser you guys reccomend?

    ATL / WTL / STL c++ question com xml

  • Serializing objects using XLM
    E Ernesto D

    Hi, is there an "easy" way to save the state of an object to a file without using MFC or COM objects? im working on a WTL project that needs to save and read a special form of "document" to file, (kind of like MFC´s Serialize()), but even tho i have the code to do it in binary mode, i would prefer to do it on XML. The documents are quite large, and consists of other objects containing several arrays of CStrings (WTL:CString that is), and primitives like ints, floats, etc. Is there a Non-MFC, Non-COM related XML parser i could use? thanks! The only stupid question is that one wich is never asked

    ATL / WTL / STL c++ question com xml

  • [wtl] Making a Wizard-Only app
    E Ernesto D

    i dont think that the error is caused by your return code, you need to step into the code on the cancel button handler and try to "isolate" the line that causes the exception, watch variables and go line by line till you find out whats wrong. If you still cant find whats wrong, post the code for your CMainWizard class so we can help you find the problem. HTH

    ATL / WTL / STL c++ json question

  • 2 questions about working with files
    E Ernesto D

    Thanks Graham!

    C / C++ / MFC c++ json oop help question

  • 2 questions about working with files
    E Ernesto D

    Hi!, i hope you guys can help me out. 1.- to get the size of a file (i dont use mfc), i use something like: HANDLE hfile=CreateFile("myfile.txt", GENERIC_READ, FILE_SHARE_READ, NULL, 0, NULL); if(hfile) { DWORD fsize=GetFileSize(hfile, NULL); CloseHandle(hfile); } is there a better way? like one that doesnt require using W32 API calls? (to keep the code portable) 2.- i now want to read from a file, using ifstream class, but the ifstream::read()function takes an int as the ammount of data to read! what if i want to read say 20MB of data? wont it overflow? . and also (ok ok its 3 questions), is there a better way to read binary (not text) data from a file? i could use the W32 APIs like ReadFile(), ReadFileEx(), etc. but i would like to keep my code as portable and object oriented as possible thanks!

    C / C++ / MFC c++ json oop help question

  • Getting version of installed MS data objects
    E Ernesto D

    Thanks :)

    C / C++ / MFC windows-admin question announcement

  • Getting version of installed MS data objects
    E Ernesto D

    Hi, is there a registry entry, file to look for, or some way for my program to find out what (if any) version of the microsoft data objects is present on the computer? Thanks!

    C / C++ / MFC windows-admin question announcement

  • Getting the -REAL- printable area of a page
    E Ernesto D

    Hi all, to get the real printable area of a page (on a printer of course) is it correct to do it like this? assuming that i want to use HIMETRIC, mydc is a device context (CDC class), and it has allready been "opened" to my printer... dc.SetMapMode(MM_HIMETRIC); CSize pagesize; // get the "physical" size of the page... pagesize.cx=dc.GetDeviceCaps(PHYSICALWIDTH); pagesize.cy=dc.GetDeviceCaps(PHYSICALHEIGHT); // now take off the non printable area pagesize.cx-=dc.GetDeviceCaps(PHYSICALOFFSETX); pagesize.cy-=dc.GetDeviceCaps(PHYSICALOFFSETY); // returned values were in device units, we need himetric dc.DPtoHIMETRIC(&pagesize); // pagesize now has the real printable area of the page is this correct? is there a better way? thanks!

    C / C++ / MFC question learning

  • "Small" bug in CSimpleArray ???
    E Ernesto D

    Thanks, ibe found what the problem is, check out the implementation of the CSimpleArray class template included in VC6: BOOL RemoveAt(int nIndex) { if(nIndex != (m_nSize - 1)) { m_aT[nIndex].~T(); memmove((void*)&m_aT[nIndex], (void*)&m_aT[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(T)); } m_nSize--; return TRUE; } as you can notice, if you remove the last element, the element is NOT destroyed. ibe been told however, that this "small glitch" is fixed in .NET, i guess the rest of us "mortals" using VC6 are stuck with it.

    C / C++ / MFC data-structures performance help tutorial question

  • "Small" bug in CSimpleArray ???
    E Ernesto D

    Umm, just below this post man! :) i added it as a reply

    C / C++ / MFC data-structures performance help tutorial question

  • "Small" bug in CSimpleArray ???
    E Ernesto D

    yep, my mistake there. check out the new "real world" example ibe just posted. I got the same leak.

    C / C++ / MFC data-structures performance help tutorial question

  • "Small" bug in CSimpleArray ???
    E Ernesto D

    heres another example, this one ibe just created as a normal Win32 console app, and included afx.h and atlbase.h to my stdafx.h. Ibe just compiled & executed this, and got the same leak // leak.cpp : Defines the entry point for the console application. #include "stdafx.h" class CClass { public: CClass(){} CClass(const CClass& rv) { m_member=rv.m_member;} const CClass& operator=(const CClass& rv){m_member=rv.m_member; return *this;} CString m_member; }; int main(int argc, char* argv[]) { CClass c1; CClass c2; c1.m_member="ABC"; c2.m_member="DEF"; CSimpleArray arr; arr.Add(c1); arr.Add(c2); arr.RemoveAt(1); return 0; } the results (in debug window) after program exits are: Detected memory leaks! Dumping objects -> strcore.cpp(118) : {44} normal block at 0x003E2498, 16 bytes long. Data: < DEF > 01 00 00 00 03 00 00 00 03 00 00 00 44 45 46 00 Object dump complete. as a side note, if you remove the item at position 0 of the array instead of 1, then tere is no leak. this IS a bug in CSimpleArray isnt it?

    C / C++ / MFC data-structures performance help tutorial question

  • "Small" bug in CSimpleArray ???
    E Ernesto D

    Hi all, ibe been trying to find a memory leak for the last 5 hours, and then i discovered what i think is a "small bug" in CSimpleArray<> collection helper, here´s an example: class acls { public: CString m_str; // constructor, copy constructor, etc. here }; // in some function... // create some objects to add... acls mycls; mycls.m_str="ABC"; acls another; another.m_str="CDE"; // and create the array & add the objects CSimpleArray arr; arr.Add(mycls); arr.Add(another); arr.RemoveAt(1); this results in a memory leak pointing to the 2nd object added to the array, the interesting part is, that if you remove the very first item instead (RemoveAt(0)) there is no leak. Can NE1 suggest a way arround this that does not involve NOT using CSimpleArray? my project is allmost finished, and rewritting everything not to use these arrays would take me forever. thanks!

    C / C++ / MFC data-structures performance help tutorial question

  • constant expression in case
    E Ernesto D

    Heres the REAL deal in a file (appconsts.cpp) #include "appconsts.h" const int COLID_PLV_NAME = 0 const int COLID_PLV_PHONE = 1 const int COLID_PLV_REP = 2 and in another file (appconsts.h) wich is included everywhere... extern const int COLID_PLV_NAME; extern const int COLID_PLV_PHONE; extern const int COLID_PLV_REP; and finally, in the LVN_COLUMNCLICK handler of one of my views (appconsts.h included here of course)... switch(ColIdx) { case COLID_PLV_NAME: // do something here break; case COLID_PLV_PHONE: // more code here also break; case COLID_PLV_REP: // and more code break; default: return 0; // we dont care about other cols. }Looks right no?, but it gives me... C:\DEV\PROJECTS\BOLETAJE\1.0_CURRENT\ProvidersView.cpp(204) : error C2051: case expression not constant C:\DEV\PROJECTS\BOLETAJE\1.0_CURRENT\ProvidersView.cpp(207) : error C2051: case expression not constant C:\DEV\PROJECTS\BOLETAJE\1.0_CURRENT\ProvidersView.cpp(210) : error C2051: case expression not constant i just dont get it!

    C / C++ / MFC help question

  • constant expression in case
    E Ernesto D

    Sorry, the ":" after case is a mistake i made while writting the post ( edited the post and corrected it now), but even without it, if you try to compile the code you wrote, and assuming you declared SOME_INT as const int SOME_INT = 0; it will give you the error, but if you declare it like: #define SOME_INT 0 then it will work fine. any idea why?

    C / C++ / MFC help question

  • constant expression in case
    E Ernesto D

    Hi all, i dont get it, heres some "sample" code to explain my problem: const int SOME_INT = 100; // notice the "const" at the start int num=0; switch(num) { case SOME_INT: ATLTRACE("someint"); break; default: // whatever }; gives me: error C2051: case expression not constant. BUT: #define SOME_INT 100; // using define instead int num=0; switch(num) { case SOME_INT: ATLTRACE("someint"); break; default: // whatever }; Gives me no trouble! WTF???? "case expression not constant"???? isnt SOME_INT clearly defined as constant in the first case??

    C / C++ / MFC help question

  • Modeless dialog problem
    E Ernesto D

    im not much into MFC, but i think this can solve the problem: i assume you are loosing the pointer to the dialog cause you are creating the object inside some function, therefore when the function exits, the pointer is no longer valid (a code sample would have helped). make the pointer a member variable of the class where you want to manipulate the dialog (like CMainFrame), and then you can safely call its members. EG: class CMainFrame { CMyDialogBar* m_pBar; int OnCreate() { m_pBar=new CMyDialogBar; m_pBar->Create(); } void Whatever() { if(m_pBar!=NULL) { // you can access its public member here } } }; this is of course only "sample" code, but should give you an idea of how to do it. HTH

    C / C++ / MFC help tutorial

  • Variable argument functions- how to?
    E Ernesto D

    That looks simple enough, Thanks!

    C / C++ / MFC c++ json tutorial question

  • Variable argument functions- how to?
    E Ernesto D

    Hi all, i would like to know how to create a function that takes a variable number of arguments (parameters), you know, like the CString::Format(LPCTSTR lpszFormat, ... ). Please note that i do NOT use MFC (i use W32-API and WTL), so even if theres some class, typedef, or whatever that helps with this, but is part of MFC, it wont do me any good. Any idea of where i should start looking? Thanks!

    C / C++ / MFC c++ json tutorial 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