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
  • IPC Thru WM_COPYDATA

    debugging csharp c++ visual-studio data-structures
    9
    0 Votes
    9 Posts
    0 Views
    F
    I originally had the WM_COPYDATA as a ON_MESSAGE message map handler than I noticed the OnCopyData I wasn't able to get it to work with that as well My current method works fine as I don't have to wait for a reply with the SetEvent and shared storage thanks for your help
  • 0 Votes
    2 Posts
    1 Views
    R
    You can use a memory-mapped file with an obscure name. This won't prevent a hacker from being able to see the file but it will be far from obvious. You can obscure the data you place in the MMF by negating it or something simple like that. Another way is to use an interprocess communication mechanism. Some examples are pipes, sockets, the WM_COPYDATA message, and there are others. It is possible for a socket message to be intercepted but the other two are much more difficult to spoof.
  • PostMessage issues/questions

    c++ json help
    3
    0 Votes
    3 Posts
    0 Views
    F
    Thanks for your help my code as seems to be posting messages i added the ChaneWindowMessageFilterEx per jochen don't know if It's needed if posting in the same process and it seems that my messages to delivered
  • 0 Votes
    11 Posts
    2 Views
    P
    Your code do not behave the way you expect, and you don't understand why ! There is an almost universal solution: Run your code on debugger step by step, inspect variables. The debugger is here to show you what your code is doing and your task is to compare with what it should do. There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug. Debugger - Wikipedia, the free encyclopedia[^] Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^] The downside of this solution: - It is a DIY, you are the one tracking the problem and finding its roots, which lead to the solution. The upside of this solution: - You see your code behavior, you match it against your expectations. secondary effects - Your will be proud of finding bugs yourself. - Your skills will improve. You should find pretty quickly what is wrong. Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • Deleting Image IN VC++

    c++ help
    5
    0 Votes
    5 Posts
    0 Views
    J
    You can use the CImage Class[^]. Use the Save() function with ImageFormatGIF to save the image as GIF. How to create the CImage depends on the source. It can be loaded from file or passed an existing in memory bitmap.
  • Coding on hostel mannagement in c program

    com
    4
    0 Votes
    4 Posts
    0 Views
    P
    We do not do your HomeWork. HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them. Any failure of you will help your teacher spot your weaknesses and set remedial actions. So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help. As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better. When you just ask for the solution, it is like trying to learn to drive a car by having someone else training. Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem. Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • Disable a Tab on CPropertySheet

    c++ help tutorial question
    4
    0 Votes
    4 Posts
    0 Views
    D
    I sent you a link to a working solution. I've used it in several projects. "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
  • IM chat question

    question asp-net lounge
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Stupid build issue - has to be an include file issue....

    help c++ tools question
    4
    0 Votes
    4 Posts
    0 Views
    C
    Leon - yes, yes, you are correct. It is for a CE, Windows Embedded Compact, a Smart Device, and let's see what does Microsoft call them now? Hmm IoT or something. Note: Quote: If I create a simple smartdevice dialog application, my PC builds it fine All of the defaults are set up by VS2008, so I admittedly was hoping for a "oh, yeah, I've seen that before" response. Nothing magic here, this is a completely default mfc dlg app that is the default framework of an application. This is an argument between VS2008 and I think the SDK, and years ago, I solved this. Just having a senior moment. Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
  • I tried PostMessage as well

    3
    0 Votes
    3 Posts
    0 Views
    L
    The child probably wont see the message because the parent isn't passing it up. Very few messages are passed from a parent to a child unless you specify it beyond the obvious stuff like keyboard and mouse. Depending on the ID it isn't clear to me a message will be passed to a child window I need to know more about the window types and flags involved. In vino veritas
  • help me write a program

    help
    14
    0 Votes
    14 Posts
    2 Views
    D
    Member 12968703 wrote: if (pass==number) Comparing an int to a float will rarely, if ever, work. Member 12968703 wrote: but i dont know how to make a prompted to re enter a password if i enter a wrong password..i really dont know..and i hope u can help me.. To continue the prompting until the correct password is entered, you'll need to use a loop. Something like: do { ... } while (password != 12345); "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
  • Problem Creating C++ Console App

    help csharp c++ question
    5
    0 Votes
    5 Posts
    0 Views
    P
    Asking questions is a skill[^] Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • how do i write this program?

    question help
    4
    0 Votes
    4 Posts
    0 Views
    P
    When you don't understand what your code is doing or why it does what it does, the answer is debugger. Use the debugger to see what your code is doing. It allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool. Debugger - Wikipedia, the free encyclopedia[^] Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^] The debugger is here to show you what your code is doing and your task is to compare with what it should do. There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug. Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
  • 0 Votes
    8 Posts
    0 Views
    S
    Hi Stefan... Thanks for the observation. And yes, I have been pursuing this same line. I am having trouble getting a reply from the the third party vendor. Meanwhile, other matters have pushed this to the side, so I haven't been giving it a lot of attention. I will leave this reply up for the weekend, then remove/resolve this message. Thanks again and have a great weekend. SPC
  • Performance issue when drawing on MFC

    c++ graphics help question performance
    5
    0 Votes
    5 Posts
    0 Views
    L
    No worries and since you came back can I offer you a piece of code that can very quickly reject all the trivial shape areas that do not require drawing when moving in your current code. You need to set the "dragging" flag to TRUE when you are moving a shape and set it back to FALSE when done dragging. I don't have the structures so you need to feed in x1,y1,x2,y2 into the two /* xxxxx */. So for each Area x1,y1 needs to be top left corner, x2,y2 lower right corner of the on screen minimum box around the shape. It puts an extra very fast test on redrawing a shape if the flag is set and I will leave you to work out what it does but it is commented :-) BOOL CanAreasOverlap (int Area1_x1, int Area1_y1, int Area1_x2, int Area1_y2, int Area2_x1, int Area2_y1, int Area2_x2, int Area2_y2){ if (Area1_x1 > Area2_x2) return (FALSE); // Area 1 completely to the right of Area 2 and can't overlap if (Area1_x2 < Area2_x1) return (FALSE); // Area 1 completely to the left of Area 2 and can't overlap if (Area1_y1 > Area2_y2) return (FALSE); // Area 1 completely below Area 2 and can't overlap if (Area1_y2 < Area2_y1) return (FALSE); // Area 1 completely above Area2 and can't overlap return (TRUE); // The two square areas overlap to some degree } /* Set the dragging flag to TRUE when moving a shape */ BOOL dragging = FALSE; OnDraw(CDC* pDC){ for (int i = 0; i < numberObjects; i++){ if ((!dragging) || CanAreasOverlap(/\* Moving shape is area 1\*/, /\*objects\[i\] shape is area 2\*/)) { objects\[i\]->DrawShape(pDC); } } } When you drag a shape and go to redraw In vino veritas
  • 0 Votes
    1 Posts
    0 Views
    No one has replied
  • Gdiplus: DrawImage not working

    graphics help csharp c++ visual-studio
    3
    0 Votes
    3 Posts
    0 Views
    U
    Actually the problem was related to the way of copying from srcHDC to ImageHDC. I have done like this: HDC svgDC = cairo_win32_surface_get_dc(surface); image.Create(width, height, 32); image.SetHasAlphaChannel(TRUE); HDC imageHDC = image.GetDC(); BLENDFUNCTION blend = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; AlphaBlend(imageHDC, 0, 0, width, height, svgDC, 0, 0, width, height, blend); image.ReleaseDC(); Best regards!
  • Multithreading question

    question
    16
    0 Votes
    16 Posts
    0 Views
    M
    If you get this then you need to use thread synchronisaiton so that WHATEVER happens, and it will, one day, your threads process data and events in a coordinated fashion.
  • free memory when constructor throw exception

    performance
    4
    0 Votes
    4 Posts
    2 Views
    A
    Decently well though out description of the problem and solutions: C++ Constructors and Memory Leaks - J@ArangoDB[^]
  • Send data to POS Printer by USB

    c++ help tutorial
    3
    0 Votes
    3 Posts
    3 Views
    D
    Just a guess, but have you tried something like: CreateFile("\\\\.\\USB#VID_0781&PID_5530#077443117B924E40#{a5dcbf10-6530-11d2-901f-00c04fb951ed}", ...); or if your USB drive has a drive letter mapped to it: CreateFile("\\\\.\\D:", ...); "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