Hi folks,
I´ve got another problem to fix.
I want to show a little bitmap as a preview out of the entrie, marked in my textbox....
Compiling is correct, but the existing bitmap is never shown.
This is the code:
case ID_LOOK:
/** if clicked, there is shown a previewof the marked item **************/
/** Get marked Item from ID_BOX**********/
hList = GetDlgItem(hwndDlg, ID_BOX);
int read = SendMessage(hList, LB_GETCURSEL , 0, 0);
if (read<0) return TRUE;
LB_GETTEXTLEN;
SendMessage(hList, LB_GETTEXT,read, (LPARAM)pfad);
Sleep(100);
/** if another item is marked, set pfad2 to 0 ************/
pfad2[0] = 0;
/** get the path to the Bitmap ******************/
wcscat(pfad2, L"\\Storage Card\\GoPalWorld-Skin\\Designs\\Autotauscher\\");
wcscat(pfad2, pfad);
wcscat(pfad2, L"\\icon.bmp\0");
/** test to copy the bitmap to the root of Storage Card ***********/
if(CopyFile(pfad2, L"\\Storage Card\\icon.bmp", FALSE) != TRUE)
{MessageBox(0,L"Vorschau-Bild existiert nicht!",L"Fehler",0);} // if copying faults send Message to the user
else
{
/** show bitmap out of marked folder in ID_BOX on hwndDlg at x = 60, y= 100 **/
if(hBitmap) DeleteObject(hBitmap); // delete "old" Bitmap
hBitmap = LoadBitmap(NULL, L"\\Storage Card\\icon.bmp\0"); // Test to load bitmap from SD-card
// hBitmap = LoadBitmap(NULL, pfad2); // normal procedure with variable
HDC hdc = GetDC(hwndDlg);
HDC hdcMem = CreateCompatibleDC(hdc);
HGDIOBJ hbOld = SelectObject(hdcMem,hBitmap);
BitBlt(hdc, 60, 100, 50, 50, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem,hbOld);
DeleteDC(hdcMem);
ReleaseDC(hwndDlg,hdc);
InvalidateRect(hwndDlg,0,TRUE);
}
break;
What is going wrong with this code?
The program runs on CE5 and CE6 but the bitmap is never shown on hwnDlg... ???
Greetings
Peter
No help? ???
LoadBitmap()
This function loads the specified bitmap resource from the executable file for a module.
HBITMAP LoadBitmap(
HINSTANCE hInstance,
LPCTSTR lpBitmapName
);
SHLoadDIBitmap()
http://msdn.microsoft.com/en-us/library/aa453720.aspx
Peter, it is a good idea to check the return value after calling a function.
John
Quote from: timovjl on October 21, 2010, 08:20:58 AM
LoadBitmap()
This function loads the specified bitmap resource from the executable file for a module.
HBITMAP LoadBitmap(
HINSTANCE hInstance,
LPCTSTR lpBitmapName
);
SHLoadDIBitmap()
http://msdn.microsoft.com/en-us/library/aa453720.aspx
Hi timovjl,
your posting was great!!!...
hbit = SHLoadDIBitmap(pfad2);
HWND imgCtrl = CreateWindow( _T("STATIC"), L"Auto", SS_LEFT | SS_BITMAP | WS_VISIBLE, 40, 120 , 50, 50, hwnd1, NULL, NULL, NULL);
SendMessage(imgCtrl,STM_SETIMAGE, (WPARAM)IMAGE_BITMAP,(LPARAM)hbit);
The only rub in it is, that you can´t set the window WS_CHILD. I will look if I can handles that another way, but it works so far.
thanks a lot
Greets
Pitter