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

Eugen Podsypalnikov

@Eugen Podsypalnikov
About
Posts
402
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Is there a way to move the right-most button of a CMFCToolbar to the right most position (of the rect) ?
    E Eugen Podsypalnikov

    Yes, of course... :)

    // CYourToolBar : public CMfcToolBar

    /*virtual*/ void CYourToolBar::AdjustLocations()
    {
    __super::AdjustLocations();

    if (GetSafeHwnd())
    {
    int iCount(GetCount());
    if (iCount)
    {
    CRect crClient(0, 0, 0, 0);
    GetClientRect(crClient);

      CMFCToolBarButton\* pcButton(GetButton(iCount - 1));
      if (pcButton)
      {
        CRect crPos(pcButton->Rect());
        if (crClient.right > crPos.right)
        {
          crPos.OffsetRect(crClient.right - crPos.right, 0);
          pcButton->SetRect(crPos);
          UpdateTooltips();
        }
      }
    }
    

    }
    }

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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

  • Memory leak problem
    E Eugen Podsypalnikov

    Before you are starting the debug session from VS: - Ctrl+Alt+E (Exceptions Dialog from the Debug Menu) - Check the all boxes there in - F5 (Start) The Debugger will stop exactly at the "bugged" line :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC help c++ sysadmin data-structures performance

  • Extract RGB Colors
    E Eugen Podsypalnikov

    Just mask the bits[^] out :) (do you still need some help ?)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC question

  • Replacement for Inline Assembly
    E Eugen Podsypalnikov

    // how can I execute a jmp instruction when I need to? 1. Organize a buffer for the JMP executing

    enum {
    #ifndef _WIN64
    jmpAddrIdx = 2, // Index of the Address in Jump-Buffer
    jmpLen = 10, // Length of the Jump-Buffer
    #else
    jmpAddrIdx = 3, // Index of the Address in Jump-Buffer
    jmpLen = 16, // Length of the Jump-Buffer
    #endif
    };
    static BYTE jmp[jmpLen] = {
    #ifdef _WIN64
    0x50, // push rax (len:01)
    0x48, 0xb8, // mov rax, DWORD_PTR (len:10)
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x48, 0x87, 0x04, 0x24, // xchg rax, [rsp] (len:04)
    0xc3 // ret (len:01)
    #else
    0x50, // push eax (len:01)
    0xb8, // mov eax, DWORD_PTR (len:05)
    0x00, 0x00, 0x00, 0x00,
    0x87, 0x04, 0x24, // xchg eax, [esp] (len:03)
    0xc3 // ret (len:01)
    #endif
    };

    2. Fill the address part there in (low Bytes first)

      memcpy(&jmp\[jmpAddrIdx\], YOUR\_DESIRED\_ADDRESS, sizeof(DWORD\_PTR));
    

    3. Take the pointer of an existing global function(void) (Long enough: see jmpLen above) 4. Mark the addressed space of the function as writeable

    DWORD dwOldMode(0);
    if (VirtualProtect(pfnYourShellFcn, jmpLen, PAGE_EXECUTE_READWRITE, &dwOldMode)) {

    5. Write the jump into the function :)

    memcpy(pfnOriginal, jmp, jmpLen);

    6. Mark the space as original

    VirtualProtect(pfnYourShellFcn, jmpLen, dwOldMode, &dwOldMode);

    7. Call the pointed function :)

    (*pfnYourShellFcn)()

    8. Be thrilled.

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC question c++

  • Always write to top of file
    E Eugen Podsypalnikov

    // I do not want to Append text, just write the same 100 lines of text each time at the top of the file. Any appending in the file context is more rapid than an inserting. Of course, you could try to append the reversed content to be read later as reversed as well... :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC help

  • CTreeCtrl, CDockingPane, and mouse events
    E Eugen Podsypalnikov

    Hm... My trees can register the double clicks in their floating panes :) For example, it is possible to extend a node by the double click at its item... The model in my case is (from outside): CXDocablePane->CXFrameWndEx->CXTreeCtrl :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC php css database com beta-testing

  • Linked Lists and unique_ptr's
    E Eugen Podsypalnikov

    Hm... Try it :) :

    node a(3); // a, will be deleted as a stack variable
    a.next = new node(4); // b, will be deleted by unique_ptr of a
    a.next->next = new node(5); // c, will be deleted by unique_ptr of b
    // 1. deleting of b, not "tested" :) :
    a.next = move(a.next->next); // is there a crash ?
    // 2. then deleting of b, old style :) :
    unique_ptr temp = move(a.next->next);
    a.next = move(temp);

    PS: any pre 0x11 C++ strcture or class may have a destructor as well :

    struct node {
    int m_iData;
    node* m_pNext;

    node(int iData) : m_iData(iData), m_pNext(NULL) {}
    ~node() { delete m_pNext; }

    node* detach() { node* prevNext(m_pNext); m_pNext = NULL; return prevNext; }
    } a(3);

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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

  • Exceptions handler question
    E Eugen Podsypalnikov

    // don't know where in your code it happened Let your debugger stop at any exception (IDE::Ctrl+Alt+E in a loaded solution) :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC question

  • Accessing Pixels with CreateDIBSection
    E Eugen Podsypalnikov

    The width of the bitmap is in pixels (DWORDs) and your buffer is in BYTEs ... :) PS: You can use all GDI functions in the memory-DC as well.

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC graphics help question

  • How to check if a character is from keyboard in MFC
    E Eugen Podsypalnikov

    void aChinaGarbageTest()
    {
    ASSERT(31 < _TCHAR('武') && _TCHAR('武') < 128);
    }

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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

  • Messagebox
    E Eugen Podsypalnikov

    Why is the owner (the first parameter of ::MessageBox(..)) important and may not be NULL ? :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC asp-net help

  • How to check if a character is from keyboard in MFC
    E Eugen Podsypalnikov

    Andraw111 wrote:

    but sometimes there are some garbage values at the end of descrtion string tail, I want to remove them.

    - What type of the string is used ? - Is the garbage offset allways the same ? - Does the get-methode return the length of its answer as well ? :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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

  • CB_SELECTSTRING related question
    E Eugen Podsypalnikov

    It should return a zero-based index... :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC question help tutorial learning

  • CB_SELECTSTRING related question
    E Eugen Podsypalnikov

    Try to use the result of CB_FINDSTRINGEXACT for CB_SETCURSEL :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC question help tutorial learning

  • Determine straight line
    E Eugen Podsypalnikov

    - Take the first and last points to build the 3D law of their straightness - Define the fluctuation radius as "allowed error" - All other points must lie in the "pipe" => => any point projection onto the law(1) may not be greather as the radius(2) :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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

  • Tab control
    E Eugen Podsypalnikov

    Why not in the same manner ? :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC help tutorial

  • Can a WorkerThread do a SendMessage to a CDialog
    E Eugen Podsypalnikov

    Do you have such an "if" statement ? :) :

    {
    //..

    HWND hDlg = g_pcDialog->GetSafeHwnd();
    if (hDlg) {
    ::SendMessage(hDlg, WM_COMMAND, IDOK, 0);
    }

    //..
    }

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC

  • Can a WorkerThread do a SendMessage to a CDialog
    E Eugen Podsypalnikov

    Please answer :) : - Whereby does the secondory thread know the dialog ? - When will the first message be sent ?

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC

  • How to read and write struct using CArchive file?
    E Eugen Podsypalnikov

    See also :) :

    void TestExchange(CArchive& ar, POINT& pt)
    {
    if (ar.IsStoring()) {
    ar.Write(&pt, sizeof(POINT));
    } else {
    ar.Read(&pt, sizeof(POINT));
    }
    }

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

    C / C++ / MFC help tutorial question

  • CInvalidArg exceptions
    E Eugen Podsypalnikov

    // What Causes a CInvalid Arg Exceptions ?? An invalid dialog's handle, for example :)

    They sought it with thimbles, they sought it with care; They pursued it with forks and hope; They threatened its life with a railway-share; They charmed it with smiles and soap. :)

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