{"id":647,"date":"2021-09-14T22:59:37","date_gmt":"2021-09-14T22:59:37","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=647"},"modified":"2021-09-27T19:38:26","modified_gmt":"2021-09-27T19:38:26","slug":"c-drawing-bitmap-onto-dialog","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/c-drawing-bitmap-onto-dialog\/8629.html","title":{"rendered":"C++, drawing bitmap onto dialog"},"content":{"rendered":"<p>I am making a Win32 application using MS visual C++ 6. My problem is that i can&#8217;t draw a bitmap resource on to a dialog. Here is a section of what my source code looks like:<\/p>\n<p>#include &#8220;stdafx.h&#8221;<br \/>\n#include &#8220;resource.h&#8221;<\/p>\n<p>HINSTANCE hInstance;<\/p>\n<p>LRESULT CALLBACK DlgProc(HWND , UINT , WPARAM , LPARAM);<br \/>\nLRESULT CALLBACK MainDlgProc(HWND , UINT , WPARAM , LPARAM);<br \/>\nLRESULT CALLBACK AbtDlgProc(HWND , UINT , WPARAM , LPARAM);<br \/>\n\/\/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br \/>\nint APIENTRY WinMain(HINSTANCE hInstance,<br \/>\nHINSTANCE hPrevInstance,<br \/>\nLPSTR lpCmdLine,<br \/>\nint nCmdShow)<br \/>\n{<br \/>\nDialogBox(NULL, MAKEINTRESOURCE(IDD_PwChk), NULL, (DLGPROC)DlgProc);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>LRESULT CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)<br \/>\n{<br \/>\nchar szPassword[11]={0};<br \/>\nswitch(msg)<br \/>\n{<br \/>\ncase WM_PAINT:<br \/>\n{<br \/>\nHBITMAP hBitmap = (HBITMAP)LoadImage(hInstance, &#8220;IDB_pwTitle&#8221;, IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE);<br \/>\nHDC hdc = GetDC(hWnd);<br \/>\nHDC image_dc = CreateCompatibleDC(hdc);<br \/>\nHBITMAP old_hbitmap = (HBITMAP)SelectObject(image_dc, hBitmap);<br \/>\nBitBlt(hdc ,10 , 10, 10, 10, image_dc, 0, 0, SRCCOPY);<br \/>\nbreak;<br \/>\n}<\/p>\n<p>Can any1 tell me when i&#8217;m doing wrong?<br \/>\nI also use dialog resources and disply them using the DialogBox function, the reson why i don&#8217;t draw the image onto the dialog resource in the resource editor is because when i do this the images are not displayed in WindowsXP<\/p>\n<p>Does any1 have an answer?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":11},"question-category":[55],"question_tags":[],"class_list":["post-647","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=647"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=647"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=647"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}