Click here to Skip to main content
15,885,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 6:46
PotatoSoup6-Apr-20 6:46 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Richard MacCutchan6-Apr-20 7:04
mveRichard MacCutchan6-Apr-20 7:04 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 7:26
PotatoSoup6-Apr-20 7:26 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:24
Victor Nijegorodov6-Apr-20 8:24 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 8:43
PotatoSoup6-Apr-20 8:43 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:49
Victor Nijegorodov6-Apr-20 8:49 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:07
PotatoSoup6-Apr-20 11:07 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
leon de boer6-Apr-20 21:06
leon de boer6-Apr-20 21:06 
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


modified 7-Apr-20 3:30am.

SuggestionRe: How do I add listboxes to a back buffer and use that? Pin
David Crow6-Apr-20 8:59
David Crow6-Apr-20 8:59 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:31
PotatoSoup6-Apr-20 11:31 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Greg Utas6-Apr-20 12:39
professionalGreg Utas6-Apr-20 12:39 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 12:52
PotatoSoup6-Apr-20 12:52 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Greg Utas6-Apr-20 12:55
professionalGreg Utas6-Apr-20 12:55 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 18:58
PotatoSoup6-Apr-20 18:58 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Greg Utas7-Apr-20 0:05
professionalGreg Utas7-Apr-20 0:05 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 20:42
Victor Nijegorodov6-Apr-20 20:42 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Member 1507871612-Jul-22 14:20
Member 1507871612-Jul-22 14:20 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Richard MacCutchan6-Apr-20 21:42
mveRichard MacCutchan6-Apr-20 21:42 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup9-Apr-20 8:50
PotatoSoup9-Apr-20 8:50 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov9-Apr-20 22:12
Victor Nijegorodov9-Apr-20 22:12 
AnswerRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:59
PotatoSoup6-Apr-20 11:59 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
leon de boer6-Apr-20 20:42
leon de boer6-Apr-20 20:42 
AnswerRe: How do I add listboxes to a back buffer and use that? Pin
leon de boer6-Apr-20 20:31
leon de boer6-Apr-20 20:31 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup7-Apr-20 18:08
PotatoSoup7-Apr-20 18:08 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
leon de boer7-Apr-20 19:05
leon de boer7-Apr-20 19:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.