Skip to content

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
  • 0 Votes
    8 Posts
    0 Views
    L
    You aren't getting that memory DC's are basically free you aren't limited to just one and why they exist :-) Lets see if I can make you understand. This stuff is only important for bitmaps you can print text all day and never need to know this stuff 1.) When you print bitmaps you make a new memory DC to match the printer not the screen!!!! HDC SecondDC = CreateCompatibleDC( >>> PrinterDC <<<); 2.) Put your image on the memory DC and you use it to print .. just like you did the screen DC 3.) Now print it. 4.) Now you destroy the memory DC that matches the printer you are done with it. At no point in that did I change or alter your screen bitmap/DC What you aren't grasping is why you need a memory DC .. so lets deal with that because it is important. So a true device DC may have a different planes and colour layout to your image and if that was done at a driver level, every driver would have to know how to deal with every colour format. So they don't do that the driver generally knows exactly one colour format usually RGB. The memory context is the thing that knows all the different formats and is essentially device independent. So when you want to print what a bitmap what you want is a memory context that matches the PRINTER DC not the screen. That is all covered here .. I want you to carefully read the paragraph that starts with "The original bitmap in a memory DC is simply a placeholder" Memory Device Contexts | Microsoft Docs[^] Now here is a tutorial on bitmap printing I want you to go to Part 9 https://www.dreamincode.net/forums/topic/261009-bitmap-printing-tutorial-in-c-win32/ I want you to take particular note of lines 9 to 13 which does this prn = GetPrinterDC(hwnd); cxpage = GetDeviceCaps (prn, HORZRES); cypage = GetDeviceCaps (prn, VERTRES); hdcMem = CreateCompatibleDC(prn); HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hBitmap); If you understood the above you will understand what they are doing but lets walk thru it 1.) They got the printer DC because that is our device NOT the screen 2.) They got the width and height of the printer from that DC. 3.) They made a memory DC to the printer DC to transfer the image onto (printer D
  • confusion about fonts in Windows

    com graphics tutorial question
    7
    0 Votes
    7 Posts
    0 Views
    A
    Ah, the crucial thing I didn't realize is that it does no harm to set things one doesn't care about to 0. This is particularly helpful with the width field - I was afraid I was going to have to figure out what ratio of height to width displays the characters without distortion, and use it to calculate what width I need for each desired height, but I've tried a few different height values just now with the width set to 0 and it stays proportional. Excellent. I held off for a while to see whether I had any more questions - sizing would have been the next issue - but I think I have those all worked out too. Thanks for the help.
  • need help with unix commands

    c++ help tutorial
    6
    0 Votes
    6 Posts
    0 Views
    L
    I suspect it's a mixture. Some teachers are not so good, some students lack the ability, some are lazy. But I suspect we never hear from the ones who do have good teachers, and ability, and are prepared to try things for themselves.
  • Unable to receive custom Ethernet frame

    question
    12
    0 Votes
    12 Posts
    1 Views
    F
    i"m interested in c and c++.im provide the link and please visited my website [url=https://www.imgsrc.com/\]imgsrc[/url]
  • lmao who uses MFC still

    c++ javascript question
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • C++ developer chance from top hedge fund in china

    c++
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • C++ developer chance from top hedge fund in china

    c++
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • MovePrev() throwing 265926 error code (End Of RowsSet).

    help c++ question
    15
    0 Votes
    15 Posts
    0 Views
    U
    QASolved, a prominent name among the best & most affordable QuickBooks ProAdvisor Assistant in the US offers cost-efficient <QuickBooks ProAdvisor Support (877) 263-2742 specifically designed to cater to small businesses within the US region. Call us today to get in touch with a QB ProAdvisor in your area.
  • Invalid operands

    help question
    6
    0 Votes
    6 Posts
    0 Views
    CPalliniC
    You have to comply with the assigned interface, but such interface would probably make your Fibonacci series computation rather clumsy. I suggest you to separate the tasks: write a fibonacci function complying with the required interface wich, in turn, calls a trivial recursive implementation (say myfib) of the series computation: #include struct args { int number; int result; }; // trivial recursive implementation on Fibonacci series computation static int myfib( int n ) { if ( n < 3 ) return 1; else return myfib(n-1) + myfib(n-2); } // the interface compliant function void fibonacci( void * arguments ) { struct args * pargs = (struct args *) arguments; pargs->result = myfib( pargs->number); // call the private workhorse } // test program int main() { struct args a = { 10, 0 }; fibonacci( &a ); printf("fibonacci(%d)=%d\n", a.number, a.result); return 0; }
  • 0 Votes
    2 Posts
    0 Views
    CPalliniC
    index & 0x01 It is a test on last bit of the index variable: it is 1 when index is odd (0 when index is even).
  • 0 Votes
    8 Posts
    0 Views
    M
    You can use a product such as [Code Jock](http://www.codejock.com/) which is a layer above MFC or .NET - Michael Haephrati מיכאל האפרתי
  • Using Alternate Memory Heaps

    c++ performance question
    6
    0 Votes
    6 Posts
    0 Views
    Richard Andrew x64R
    Thank you. :) The difficult we do right away... ...the impossible takes slightly longer.
  • 0 Votes
    4 Posts
    0 Views
    M
    I've got it working with m_PositionListBox.SetItemState(-1, 0, LVIS_SELECTED| LVIS_FOCUSED); m_PositionListBox.SetItemState(currentStep - 1, LVIS_SELECTED| LVIS_FOCUSED, LVIS_SELECTED| LVIS_FOCUSED); Thanks. I'd rather be phishing!
  • Iterating over an indefinitely large number of concentric loops

    career
    2
    0 Votes
    2 Posts
    0 Views
    L
    HOW TO ASK A QUESTION - C / C++ / MFC Discussion Boards[^].
  • C++ Vector object question

    data-structures question c++ graphics
    11
    0 Votes
    11 Posts
    0 Views
    S
    Thanks, I understood
  • 0 Votes
    9 Posts
    2 Views
    L
    There is something truly sublime about that code. :)
  • Retrieve HWND of a control that has focus

    question visual-studio com
    12
    0 Votes
    12 Posts
    1 Views
    L
    Some comments: 1.) If you are not the author of the target process then from a purely conceptual point of view you are attacking the process. The [modern UWP applications](https://docs.microsoft.com/en-us/windows/uwp/get-started/universal-application-platform-guide) will limit these types of cross process interactions. You should check if the target process supports [Active Accessibility, UI Automation, or IAccessibleEx](https://docs.microsoft.com/en-us/windows/desktop/WinAuto/microsoft-active-accessibility-and-ui-automation-compared). 2.) If you need to send input such as WM_CHAR to a window owned by another process you may need to use the [AttachThreadInput function](https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-attachthreadinput) before sending the WM_CHAR or other input messages. 3.) The [SetWindowText function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms633546(v=vs.85).aspx) can only be used in the current process. It cannot be used to set the text in a window owned by another process. 4.) To set the text of a window in another process you will need to send the WM_SETTEXT message directly. 5.) The [SendMessage function](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644950(v=vs.85).aspx) can cause your program to hang. Use [SendMessageTimeout](https://msdn.microsoft.com/en-us/library/windows/desktop/ms644952(v=vs.85).aspx) instead. 6.) You will need to make sure that the process setting the text is of greater or equal [integrity levels](https://msdn.microsoft.com/en-us/library/bb625963.aspx?f=255). For example... a process running at medium level cannot set the text in a window owned by a process running at high integrity level. Best Wishes, -David Delaune P.S. The solution to your problem is in bold.
  • 0 Votes
    10 Posts
    0 Views
    D
    You are not rebuilding the array to match what it would look like after all the rotations. You are looking at a single index in the array. The logic applies to what is the effect of a rotation to that index alone - not the whole array. Socialism is the Axe Body Spray of political ideologies: It never does what it claims to do, but people too young to know better keep buying it anyway. (Glenn Reynolds)
  • 0 Votes
    5 Posts
    0 Views
    CPalliniC
    You have first to fix your grammar, removing left recursion. See, for instance: CS 3721 Programming Languages Recursive Descent Parsing.
  • 0 Votes
    2 Posts
    1 Views
    U
    Did you fix your problem? I also want to get the status, could you please share your solution to me ?