Click here to Skip to main content
14,542,702 members

C / C++ / MFC

 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 6:46
MemberPotatoSoup6-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
MemberPotatoSoup6-Apr-20 7:26 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:24
MemberVictor Nijegorodov6-Apr-20 8:24 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 8:43
MemberPotatoSoup6-Apr-20 8:43 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:49
MemberVictor Nijegorodov6-Apr-20 8:49 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:07
MemberPotatoSoup6-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
Memberleon 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
MemberDavid Crow6-Apr-20 8:59 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:31
MemberPotatoSoup6-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
MemberPotatoSoup6-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
MemberPotatoSoup6-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
MemberVictor Nijegorodov6-Apr-20 20:42 
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
MemberPotatoSoup9-Apr-20 8:50 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov9-Apr-20 22:12
MemberVictor Nijegorodov9-Apr-20 22:12 
AnswerRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:59
MemberPotatoSoup6-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
Memberleon 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
Memberleon 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
MemberPotatoSoup7-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
Memberleon de boer7-Apr-20 19:05 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Richard MacCutchan7-Apr-20 21:58
mveRichard MacCutchan7-Apr-20 21:58 

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.