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
L

leon de boer

@leon de boer
About
Posts
623
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Embedded and dynamic memory allocation
    L leon de boer

    Embedded includes very large systems and processors these days and dynamic allocation has become very common on those. Even with an RTOS on a smaller micro they will typically use dynamic allocation and support most options FreeRTOS is typical and as you see there are 5 options on it FreeRTOS - Memory management options for the FreeRTOS small footprint, professional grade, real time kernel (scheduler)[^] Perhaps to give a more informed answer we need need to know what your intended system is.

    In vino veritas

    C / C++ / MFC design hardware com graphics iot

  • Does FreeRTOS have built-in support for queues that can hold variable sized elements?
    L leon de boer

    Generally you would have a circular queue of pointers to struct on the transmission queue. You don't want to be copying data around when you don't have to and it means the transmission queue is always just a pointer that the transmission sender can check what the pointer points to. In your struct you could have for example a field which would be "size to send" and then the data. You either free the struct after sending if dynamic, or clear a flag in the struct to mark it free for reuse if using static structs. As you are feeding two threads into one queue you will also need to put a binary semaphore on queue access.

    In vino veritas

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

  • SOLVED compiler "unresolved inclusion" is not an error ?
    L leon de boer

    In Eclipse, you open the Properties of your project -> expand "C/C++ General" -> "Paths and Symbols". include dir is not right add the directory to it or fix what is there It throws that warning then goes down the search path set in enviroment and then finds it. So you end up compiling fine with a stupid warning in between.

    In vino veritas

    C / C++ / MFC announcement help question

  • OpenGL stencil not working...
    L leon de boer

    Well you failed the first part of the flow you need to enable the stencil buffer before you clear it :-)

    glEnable(GL_STENCIL_TEST); // ENABLE the stencil buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // CLEAR the stencil buffer along with colour and depth

    From there the steps are - Enable writing to the stencil buffer. - Render objects, updating the stencil buffer. - Disable writing to the stencil buffer. - Render other objects - display whole result

    In vino veritas

    C / C++ / MFC graphics com game-dev help tutorial

  • 'get_osfhandle': identifier not found
    L leon de boer

    There are very clear and compelling reasons they had to do it when they embedded linux in the windows API via WSL2. Windows then effectively has both the linux and windows functions available and it needs to know which you are wanting to call which is down to what app you are compiling a linux one or a windows one. Compatibility | Microsoft Docs[^] If you aren't aware of WSL2 in Windows 10 it's time to meet to meet it :-) Trying the New WSL 2. It's Fast! (Windows Subsystem for Linux) ― Scotch.io[^]

    In vino veritas

    C / C++ / MFC c++ visual-studio com linux help

  • computational cost of math functions
    L leon de boer

    That is more generally the compiler/optimizer responsibility. You are better off leaving that sort of thing to the end. I can highly recommend learning the whole process on a simple software renderer You will be hard pressed to find a better start point than this link because it's really a couple of simple files. GitHub - ssloy/tinyrenderer: A brief computer graphics / rendering course[^] He has a nice easy to follow sequence from raycaster to the renderer being the most complex but on 500 lines of code. Home · ssloy/tinyrenderer Wiki · GitHub[^]

    In vino veritas

    C / C++ / MFC question

  • mfc LoadBitmap hangs my application...
    L leon de boer

    I agree LoadBitmap should not fail like that but it is specified the resources are never lifted into RAM. They are tagged in special sections in the file and are excluded from the normal executable load to avoid using memory when not required. Remember a file may contain many resources for different resolutions, languages and the like and much would then be redundant duplicates hogging memory.

    In vino veritas

    C / C++ / MFC help c++ design hardware debugging

  • mfc LoadBitmap hangs my application...
    L leon de boer

    Check you have not got a clash on IDB_STOP and you actually have the resource of that ID in the project. All you need is a corrupt resource file and it can't connect the dots.

    In vino veritas

    C / C++ / MFC help c++ design hardware debugging

  • Windows CBT Hooks
    L leon de boer

    Unhook it before you post the WM_QUIT message

    In vino veritas

    C / C++ / MFC com json question

  • Windows CBT Hooks
    L leon de boer

    The unhook is usually just done in WM_DESTROY of the main application. From memory it must be before you post WM_QUIT which will kill the instance handle.

    In vino veritas

    C / C++ / MFC com json question

  • Windows CBT Hooks
    L leon de boer

    You need an instance handle to load the DLL ... guess what happens to the instance handle when the application terminates :-)

    In vino veritas

    C / C++ / MFC com json question

  • void type
    L leon de boer

    It is a historic fact, now days on C99, C11 and beyond you might more correctly use a uintptr_t. All you want really is the address but how big is that address it could be 16bits on a small micro controller, 32 bit on large CPU or 64bits on 64bit cpu. A void* pointer was usually big enough to ensure it had enough bits to point to any valid address on the CPU. So the size of a void* is completely compiler dependent. Back in the day there were also other features a void* could be cast to and from any other pointer without warning. The reason is obvious you want to be able to copy the address to a pointer of type and use normal c pointer functions. Now move forward and look at a uintptr_t this is the C99 definition in stdint.h for portability under XSI-conformant systems

    Quote:

    "an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer".

    It acts like a void* pointer with one safety added the conversion to and back is guaranteed, which never was with void* and occasionally cropped up and you can safely do it on any pointer type. It also means when you look at it in a debugger it shows as an unsigned integer rather than a pointer which is more in keeping with what it really is ... an address to somewhere in CPU memory space.

    In vino veritas

    C / C++ / MFC question

  • How do I add listboxes to a back buffer and use that?
    L leon de boer

    He is doing it runtime, go to his first post you can see he is inserting the ListBox into the main window, that code will be in the WM_CREATE of a window or WM_INITDIALOG of a dialog. I assumed in his rather crazy round about way what he was asking is to paint the ListBox to a memory DC rather than the screen DC. He seems to be calling HDC "buffers" see his names ===> HDC_of_FRONT_BUFFER Anyhow that is easy you just use the WM_PRINTCLIENT message which you subclass onto a class and handle it. WM_PRINTCLIENT message (Winuser.h) - Win32 apps | Microsoft Docs[^] You use that mainly for printing a screen capturing of a window or remote terminal programs where you need to send the screen data. So I gave him an example that does that, but he either doesn't understand or he is doing something really strange.

    In vino veritas

    C / C++ / MFC csharp c++ question wpf tools

  • How do I add listboxes to a back buffer and use that?
    L leon de boer

    You are making a mountain out of a molehill. First it was pre-compiled in the debug directory, you didn't have to compile anything Second main.ccp is stock standard C++ code will compile on any C++ windows compiler Third you can also just rename main.cpp to a main.c file remove a couple of "::" and it would compile on any C windows compiler What I do now know is your level of programming knowledge which is useful if you want me to try and help you. So basically I am reading your bitmap paint is drawing over the top of the listboxes and other windows, it would be useful to see the original code that creates the parent window. I am basically thinking you are trying to draw a bitmap where the coloured gradient occurs on my sample is that correct? Notice my listboxes draw over the top of that gradient and I could turn it to a bitmap if that helps you. I might throw up a sample doing that, note I will put just the main.c and the exe this time. Update: new sample that draws the beatyy.jpg image under the listboxes .. is that what you are trying to do? Just run the pre-compiled exe file to test GitHub - LdB-ECM/ListPlayBmp: Windows list with background Image sample[^] Or the more generic example Windows_Samples/ListJpg1 at master · LdB-ECM/Windows_Samples · GitHub[^] Anyhow lets take a couple of stabs at this 1) Check you have the WS_CLIPCHILDREN flags set on the parent window ... read what it does Window Styles (Winuser.h) - Win32 apps | Microsoft Docs[^] 2.) If all else fails because you really have cocked something just invalidate them after you paint the background (that probably means after EndPaint in your WM_PAINT message handler). Here hwnd refers to the handle of the child listbox window etc

    InvalidateRect(hwnd, NULL, TRUE);

    This explains why it forces the redraw to happen but don't use it unless you have to because it will cause the listbox to flash as it redraws and is a horrible hack.

    C / C++ / MFC csharp c++ question wpf tools

  • How do I add listboxes to a back buffer and use that?
    L leon de boer

    I am still suggesting you are doing this all wrong but I can fix this problem if you really are manually drawing the list. To me it sounds like the listbox should be a child within some other window and you are just trying to do this in some crazy manual way. If it was child it would draw itself when needed with zero code needed from you. However if you are manually doing it you could try this Copy all the code in the WM_PAINT function of your listbox and place it inside a function like so

    void PaintMyList (HWND Handle_of_ListBox, HDC Dc)
    {
    // Paste your current list box WM_PAINT code here
    }

    Now replace the PaintStruct stuff and simply us the HDC passed on the interface and use Handle_of_ListBox where you need a handle .. okay check it all compiles. So we are clear all you are using from the PaintStruct is the DC and the DC you are to use is declared on that function interface so you can remove all references to the PaintStruct. Now use a variant you posted above with the one call change

    case WM_PAINT:
    {
    PAINTSTRUCT ps;
    HDC_of_MainWindow = BeginPaint(hwnd, &ps);
    Draw_From_FRONT_BUFFER_To_MainWindow();
    PaintMyList(Handle_of_ListBox, ps.hdc); // <=== Now the list paints on the DC from the paintstruct
    EndPaint(hwnd, &ps);
    return 0;
    }
    break;

    In vino veritas

    C / C++ / MFC csharp c++ question wpf tools

  • How do I add listboxes to a back buffer and use that?
    L leon de boer

    You do not need to recreate a new listbox window NOT EVER, you can simply change the contents of the window by exchange messages and then asking the existing listbox to update. It works that way for every windows type. You see that in standard file open dialogs the directory names change in the listboxes and they aren't making new listboxes. Anyhow I gave you reference of a fairly complex listbox example on the post below for you to look at just look at main.cpp So you seem to be deeply confused about something with Windows. I am half thinking you may be talking about an Undo/Redo function for a window but not know to call it that. If you are trying to do that it is done by creating a history structure and you are creating a history window.

    In vino veritas

    C / C++ / MFC csharp c++ question wpf tools

  • How do I add listboxes to a back buffer and use that?
    L leon de boer

    Not exactly Following what you are trying to do so can I provide a reference sample GitHub - LdB-ECM/ListPlay: Windows ListBox Sample[^] That has a gradient and icons etc as sort of a complex example .. so can you explain what you are trying to do better. I don't understand why you would capture the screen image like not ever it's always faster to just draw stuff or hide/show stuff. Perhaps describe or draw a rough image of what you are trying to do on screen.

    In vino veritas

    C / C++ / MFC csharp c++ question wpf tools

  • [C++] Where to find coding examples and exercises?
    L leon de boer

    Personally you are doing it all backwards you give new graduates the company programming rules and guidelines and tell them what happens if they submit junk that doesn't conform ... which usually involves buying rounds of beers. They will have a pile of bad habits and completely unacceptable risks they picked up at uni and thought was cool and some are just dam lazy. Then you get them to try and write a simple program that conforms and discuss the errors and violations they will without doubt submit. Trust me there will be as many different coding styles as you have graduates and somehow you have to get them all to be able to read each others code as well as you. You aren't trying to stifle thinking and coding imagination but you need to get them on the same pages with standards. As for examples... Rosetta Code has hundreds Category:C - Rosetta Code[^]

    In vino veritas

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

  • TCHAR vs built in char
    L leon de boer

    The overwhelming use of it is when you want to use unicode but have the code portable for the none unicode situation. It isn't just TCHAR you use in that situation but you place all string literals inside the _T() or TEXT() macros so they also port and use the TCHAR string functions _tcslen for strlen, _tcscpy_s for strcpy_s etc so all the string functions port. So being precise about this on Visual Studio with a project open goto the last debug menu which is the project properties then goto Configuration Properties->Advanced->Character Set you now have 3 options not set (aka use ansi), use unicode and use multi-byte wide character. When you use TCHAR and the above macros and stuff in you can compile your code in any of those modes and it will work completely seamlessly. I use it a lot because I write many multilingual windows applications which have large use in non English language areas. It becomes second nature like using stdint.h and proper sized integers rather than int, short, long etc which are problematic porting.

    In vino veritas

    C / C++ / MFC visual-studio question

  • Finding a directory
    L leon de boer

    SHBrowseForFolder SHBrowseForFolderA function (shlobj_core.h) - Win32 apps | Microsoft Docs[^] CodeProject has a sample app How to Browse for a Folder[^]

    In vino veritas

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