Jump to content
  • Advertisement
Sign in to follow this  
client

Bitmap dosen't work.

This topic is 2469 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Any errors, but i can't see my bitmap in window. I also added bitmap in my project.

API.cpp

#include <windows.h>
#include <iostream>
#include <sstream>
#include <WindowsX.h>
#include <string>
#include <cstdio>
#include "resource_bg.h"
#define WIN32_LEAN_AND_MEAN
LPSTR className = "test";
UINT windowWidth = 460;
UINT windowHeight = 220;
char serverName[] = "test";
char titleText[256];
LPSTR windowName;
HBITMAP bg_bitmap;
BITMAP info_bitmap;
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam);
/////////////////////////////////////////////////////////
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){
sprintf_s(titleText, "Launcher %s", serverName);
windowName = (LPSTR)titleText;
WNDCLASSEX windowClass;
ZeroMemory (&windowClass, sizeof(WNDCLASSEX));
windowClass.cbSize = sizeof (WNDCLASSEX);
windowClass.style = CS_OWNDC;
windowClass.lpfnWndProc = WindowEventProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor (NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = className;
windowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);

if (!RegisterClassEx(&windowClass)){
MessageBox (NULL, "There is a problem with your device.", "Error",
MB_ICONEXCLAMATION | MB_OK);
return 1;
}
HWND hWindow;
hWindow = CreateWindowEx(NULL,
className,
windowName,
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
100,
100,
windowWidth,
windowHeight,
NULL,
NULL,
hInstance,
NULL);



HWND hPrzyc = CreateWindowEx( 0, "BUTTON", "Dialog", WS_CHILD | WS_VISIBLE,
5, 5, 50, 25, hWindow, NULL, hInstance, NULL );
HBITMAP bg_bitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL),MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP,0,0,0);
if(bg_bitmap==0)
{
MessageBox(0,"Problem z wczytaniem bitmapy.","Brak pliku",MB_ICONERROR);
return 0;
}
GetObject(bg_bitmap,sizeof(BITMAP),&info_bitmap);
ShowWindow (hWindow, nCmdShow);
UpdateWindow (hWindow);
// Messages loop
MSG msgStatement;
while (GetMessage(&msgStatement, NULL, 0, 0)){
TranslateMessage (&msgStatement);
DispatchMessage (&msgStatement);
}
return static_cast<int>(msgStatement.wParam);
}
/////////////////////////////////////////////////////////
LRESULT CALLBACK WindowEventProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lParam){
switch (uMsg) {
HDC hdc, hdcBitmapy;
PAINTSTRUCT ps;
case WM_PAINT: {
hdc=BeginPaint(hWindow,&ps);
hdcBitmapy=CreateCompatibleDC(hdc);
bg_bitmap=(HBITMAP)SelectObject(hdcBitmapy,bg_bitmap);
BitBlt(hdc,0,0,1000,1000,hdcBitmapy,0,0,SRCCOPY);
bg_bitmap=(HBITMAP)SelectObject(hdcBitmapy,bg_bitmap);
DeleteDC(hdcBitmapy);
EndPaint(hWindow,&ps);
break;

}
case WM_DESTROY: {
PostQuitMessage (0);
return 0;
}
}
return DefWindowProc(hWindow, uMsg, wParam, lParam);
}


resource_bg.h

#ifndef IDC_STATIC
#define IDC_STATIC (-1)
#endif
#define IDB_BITMAP2 101


bgres.rc

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource_bg.h"


//
// Bitmap resources
//
LANGUAGE 0, SUBLANG_NEUTRAL
IDB_BITMAP2 BITMAP "bitmap1.bmp"

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!