Skip to content
Code Project
CODE PROJECT For Those Who Code

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • Double buffering

    graphics performance
    6
    0 Votes
    6 Posts
    0 Views
    S
    When your dialog contains an image, and it is flickering, then you're doing the drawing at the wrong place in your code. You should place your drawing code in the OnDraw(...) callback. See http://msdn.microsoft.com/en-us/library/e6htdchf.aspx[^] GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]
  • Compiling C and C++ files together

    c++ com help announcement
    3
    0 Votes
    3 Posts
    0 Views
    L
    When using C files in a C++ unit you need to put an extern C around there include like this #include "otherstuff" // you can include other c++ unit before it extern "C" { #include "Someunit" // include you c unit } #include "morestuff" // you can include other c++ units after it In vino veritas
  • CFile Error When Writing

    help question
    9
    0 Votes
    9 Posts
    11 Views
    L
    Supercoder has given you the most likely answer although I agree with Richard you haven't conclusively shown the file is open. If the file doesn't exist you could have a problem because you probably need to open it with CFile::modeCreate | CFile::modeReadWrite Stick a debug point on the fail case and check. For the write you have a single line => pFile->Write((void*)pData, dwLength); Either 1.) pData is not a pointer to an actual array of data 2.) dwLength has not been set or exceeds the data in pData So all you have to do is work out which of the three things you got wrong and fix it. If you can't fix it we need to see how you defined pData and where you set dwLength probably. In vino veritas
  • Can I properly derive from CMFCPropertyGridColorProperty ?

    help c++ question
    6
    0 Votes
    6 Posts
    2 Views
    CPalliniC
    You could make a class inheriting from CMFCPropertyGridCtrl, say MaximilenMFCPropertyGridCtrl which only purpose is being a good friend of MyPropertyGrid. Veni, vidi, vici.
  • write Series of this program 1+-3+5+-7+9+-11 in c++

    c++ help
    6
    0 Votes
    6 Posts
    0 Views
    CPalliniC
    I see your C++ compiler is a bit dated. Veni, vidi, vici.
  • how to design the architecture?

    c++ design algorithms architecture help
    7
    0 Votes
    7 Posts
    1 Views
    F
    um...you might misunderstood me,i meants it's inconvenicent to edit *.rc file directly, for instance, adding dialog, adding strings, adding icons... it's even more inconvenient to use function: UpdateResource...
  • Position Of Taskbar in MFC

    c++ question
    3
    0 Votes
    3 Posts
    0 Views
    _
    This should do it - CWnd* tray = FindWindow(L"Shell_TrayWnd", NULL); RECT rect; tray->GetWindowRect(&rect); rect will have the screen coordinates of the taskbar. «_Superman_»  _I love work. It gives me something to do between weekends. _Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
  • 0 Votes
    3 Posts
    1 Views
    M
    I am going to say either impossible or very complex. Ask at OSR online though, that's where kernel experts hang out, someone else might have a suggestion. "The whole idea that carbon dioxide is the main cause of the recent global warming is based on a guess that was proved false by empirical evidence during the 1990s." climate-models-go-cold
  • WSACleanup delays when called how can I get around this?

    question help
    3
    0 Votes
    3 Posts
    2 Views
    U
    Sorry about the confusion - yes I am using select to make the timeout 5s. That is the timeout I would like and that part is working fine. It is the WSACleanup that isn't quickly returning that is the problem. I am hoping there is something I can do to shutdown the connect attempt before I call WSACleanup that would stop WSACleanup from taking the remaining 15s...
  • Screensaver: keyboard and mouse hook and kill screensaver

    com question lounge
    3
    0 Votes
    3 Posts
    0 Views
    D
    Today i'm find the correct way to work; i don't know why, but i'm fixed on the way to count time for starts screen saver inside my application, so i need hooks; i try to use hooks (i need global hook) and it works, but i think it's better in another way: the correct way is leave the screen saver administration to the system and enable it or disable it when occurs; the correct way is: - Read if the screen saver is enabled from the system (so i know if i have to use it) - If disabled i do nothing - If enabled, disable it - Run all on my application - If device is sleeping for 1 minute, enable screen saver and reset counting - If device is current in use, disable screen saver and reset counting The rest it' better leave to the system: in this way i have only a delay of one minute for screen saver starting. Now it works fine; i'm sorry for these post. Thank you Drugo
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • About CEdit vertical center

    question
    3
    0 Votes
    3 Posts
    2 Views
    M
    Just in case someone is searching for a solution. void CCCenterText::CenterText(CString Text) { m_wndEdit.SetWindowText(Text); m_wndEdit.CenterWindow(&m_wndStatic); // Center the edit window vertically and horizontally // Calculate the height of the font CDC \*pDC = m\_wndEdit.GetDC(); CFont \*pEditFont = m\_wndEdit.GetFont(); CFont \*pFont = pDC->SelectObject(pEditFont); TEXTMETRIC tm; pDC->GetTextMetrics(&tm); int LineHeight = tm.tmHeight; pDC->SelectObject(pFont); ReleaseDC(pDC); // Get the edit control position CRect pos; m\_wndEdit.GetWindowRect(pos); ScreenToClient(&pos); // Adjust the height position of the edit control int LineCount = m\_wndEdit.GetLineCount(); int posHeight = LineHeight \* LineCount; m\_wndEdit.SetWindowPos(&m\_wndStatic,pos.left,pos.top,pos.Width(),posHeight,0); m\_wndEdit.CenterWindow(&m\_wndStatic); }
  • How to check a DateTimeCtrl field is dirty or not in MFC

    c++ tutorial
    3
    0 Votes
    3 Posts
    0 Views
    D
    Call its GetTime() method to get the currently selected date/time from the control. Then use COleDateTime::GetStatus() to check the validity. "One man's wage rise is another man's price increase." - Harold Wilson "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
  • 0 Votes
    7 Posts
    0 Views
    D
    I try to change printer and now i don't have no more exception. Thank you so much for your answer. Bye Drugo
  • How to create lib file for header file alone.

    help tutorial question
    9
    0 Votes
    9 Posts
    2 Views
    L
    Parturiunt montes, nascetur ridiculus mus.
  • How to IP-Forwarding for Man In the Middle Attack

    tutorial question
    3
    0 Votes
    3 Posts
    1 Views
    G
    There is already at least a program that does this rather good. It's called "Ettercap". No need to reinvent the wheel. -- Gisle V.
  • 0 Votes
    3 Posts
    0 Views
    D
    Excellent idea!! Thank you, GetCurrentThreadId() will immediately and directly answer this question for me, I'll test it out this morning... Yep, GetCurrentThreadId() confirmed that the callback thread executes in the context of the initiating thread.
  • Expression in C

    help question
    2
    0 Votes
    2 Posts
    0 Views
    L
    himanshuchawla4393 wrote: and haven't read this topic yet. Then I suggest you read it; it will not help you if you just copy the answers from other people without understanding what it means. You can find all the information you need at http://msdn.microsoft.com/en-us/library/fw5abdx6.aspx[^].
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • Multiple selection on Tree Control

    com data-structures help question
    8
    0 Votes
    8 Posts
    0 Views
    M
    Sure that will be great. My email address is: mohsinmunawar [at] gmail [dot] com