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
V

Viorel

@Viorel
About
Posts
416
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • JavaScript Conditional
    V Viorel

    Since setting of href does not necessary stop the scripts and jump to new address, I think that else is required. But the code can be probably replaced with a single line like this:

    window.location.href = "...&consultar=" + accion;

    The Weird and The Wonderful javascript question discussion

  • HANDLE and FILE*
    V Viorel

    It seems easier to convert from FILE * to HANDLE:

    #include <io.h>
    #include <fcntl.h>
    
    FILE * f = . . .;
    HANDLE h = (HANDLE)_get_osfhandle(fileno(f));
    

    The other conversion looks longer:

    HANDLE h = . . .
    FILE * f = _fdopen(_open_osfhandle((intptr_t)h, _O_RDONLY), "rb");
    

    I hope this works. I am not sure mixing of operations with FILE * and HANDLE cannot be avoided.

    C / C++ / MFC com json question

  • CArchive::Close()
    V Viorel

    prasad_som wrote:

    You need to call CFile::Close before using CArchive::Close

    In my opinion the file must be closed after closing the archive. Otherwise it will be impossible to flush the last data kept in an internal buffer of CArchive. If the CFile and CArchive objects are created on the stack, then they will be closed automatically in right order.

    C / C++ / MFC question

  • conver project from MFC to Unicode enable
    V Viorel

    I think if your _wfopen function looks like this:

    _wfopen(. . ., "r");
    

    then you have to change it to this:

    _wfopen(. . ., L"r");
    

    I hope this helps.

    C / C++ / MFC c++ help

  • Can this code be better? Peer code review.
    V Viorel

    Stick^ wrote:

    [...]By unroll are you meaning something like this[...]

    Yes (actually you need one more ++: return *++code == 0). Or even like this:

    inline bool Xpdr::IsValidCode(const wchar_t * code) const
    {
        return 
            code[0] >= '0' && code[0] <= '7' &&
            code[1] >= '0' && code[1] <= '7' &&
            code[2] >= '0' && code[2] <= '7' &&
            code[3] >= '0' && code[3] <= '7' &&
            code[4] == 0;
    }
    
    C / C++ / MFC c++ tutorial question discussion code-review

  • Can this code be better? Peer code review.
    V Viorel

    I think a possible alternative solution is:

    //static
    bool Xpdr::IsValidCode(const wchar_t * code) const
    {
        for( int i = 0; i < 4; ++i, ++code)
        {
            if( *code < '0' || *code > '7')
            {
                return false;
            }
        }
        return *code == 0;
    }
    

    I hope this works. In addition you can "unroll" this short loop and replace it with a series of "if"-s and autoincremented code pointer. -- modified at 5:47 Tuesday 28th November, 2006

    C / C++ / MFC c++ tutorial question discussion code-review

  • Performance counters
    V Viorel

    In MSDN documentation. For example: http://msdn2.microsoft.com/en-us/library/56e442dc(VS.80).aspx[^].

    C / C++ / MFC performance

  • Performance counters
    V Viorel

    Since fmtValue.doubleValue is a float value, I do not think the "%d" format specifier is appropriate. You should try "%f" or "%g":

    sentinfo.Format( "%.3f", fmtValue.doubleValue);
    

    I hope this helps.

    C / C++ / MFC performance

  • resizing problem in a selfmade MDIChildFrame
    V Viorel

    It seems your m_Button and m_Chart variables were not associated with child controls. Did you create your child controls with Create member, like m_Button.Create(. . .), or in a different way? Maybe you should show us more details.

    C / C++ / MFC c++ help question

  • Changing Volume name programatically?
    V Viorel

    I think you can try this:

    SetVolumeLabel(_T("F:\\"), _T("KIRAN"));
    

    I hope this works.

    C / C++ / MFC tutorial question

  • Conversion from CString to Char * ??
    V Viorel

    A conversion like

    char * buf = (char *)(LPCTSTR)m_strAddBlob;
    

    is not correct in case of Unicode strings -- the result looks like a string consisting of the first character only. I think you first have to convert your string from Unicode to Ansi. In new MFC this can be done like this:

    CStringA ansi(m_strAddBlob);
    

    Then if you actually need a pointer to constant string, then you can use explicit cast:

    const char * buff = ansi;
    

    If you realy need a pointer to non-constant string and modify the string, then use GetBuffer and ReleaseBuffer functions:

    char * buff = ansi.GetBuffer();
    . . .
    ansi.ReleaseBuffer();
    

    I hope this helps.

    C / C++ / MFC help question

  • SHBrowseForFolder() (bis)
    V Viorel

    super_ttd wrote:

    why does intellisense tell me SHParseDisplayName() wants a LPWSTR then ?

    I cannot explain this. In my case it tells me that the first parameter is of PCWSTR type.

    C / C++ / MFC question help

  • Using static for a Large Data Structure
    V Viorel

    I think the static is for the case your array is declared locally in a function. If it is a global variable and is accessed from other modules, then do not add static (otherwise it becomes available from the current file only).

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

  • SHBrowseForFolder() (bis)
    V Viorel

    Since SHParseDisplayName requires LPCWSTR, the proposed solution should work:

    ::SHParseDisplayName(CT2W(m_strFolder), . . .);
    
    C / C++ / MFC question help

  • SHBrowseForFolder() (bis)
    V Viorel

    super_ttd wrote:

    [...] the compiler (VC7.1) complains about the A2W() macro [...]

    Try the newer improved CA2W macro. Actually I think you need CT2W macro. The correct shortest usage:

    ::SHParseDisplayName(CT2W(m_strFolder), . . .
    

    Then try the rest of the code again. I hope this helps.

    C / C++ / MFC question help

  • CListCtrl::OnCustomdrawCListCtrl(NMHDR* pNMHDR, LRESULT* pResult)
    V Viorel

    If no other solution, I think you can store the item number as a private data:

    lvItem.mask = ... | LVIF_PARAM;
    . . .
    lvItem.lParam = (LPARAM)i;
    pMatrixListResults->InsertItem(&lvItem);
    

    Later obtain this number from the NMCUSTOMDRAW structure:

    LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;
    int number = (int)pLVCD->nmcd.lItemlParam;
    

    I hope this works.

    C / C++ / MFC question

  • Function name clashing with MACRO
    V Viorel

    I think that after un-defining the definition, the original CreateWindow functions from Windows API will not be more available inside the implementation of the other CreateWindow member.

    C / C++ / MFC help tutorial

  • Shared Memory and XML File ? [modified]
    V Viorel

    Since MapViewOfFile returns a pointer to shared memory:

    LPVOID ptr = MapViewOfFile(. . .)
    

    I think you should use it as the destination in a string-copy operation:

    lstrcpyW((LPWSTR)ptr, xml)
    

    where xml is the XML string to by copied. Probably it can be obtained from your IXMLDOMDocument2 object like this:

    _bstr_t xml = myDocument->xml
    

    I hope this helps.

    C / C++ / MFC question xml json performance help

  • Question about binary String ?
    V Viorel

    I think you can try the save member of parent DOMDocument object, but it writes the entire XML document, not only your element. If you need just one element, I think you can obtain the XML representation of the node using xml property, probably like this:

    _bstr_t xml = myNode->xml;
    

    Then write this string using file functions. Note that in case of text node, the returned XML string probably will not differ very much from the value you passed to createTextNode function. I hope this helps.

    C / C++ / MFC question xml help

  • why "default Beep" windows sound is played
    V Viorel

    I think this is a feature of Windows OS -- beeping if a key cannot be processed by the focused control, like button. Maybe you should return TRUE from your PreTranslateMessage for all of your keys, thus stopping further processing? I hope this helps.

    C / C++ / MFC help 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