Hi everyone,
I am able to create GUI applications, and can create a window, but I don't know how to work with images. What commands can I use to display a picture in a window? Do you have any examples?
Thanks.
Printable View
Hi everyone,
I am able to create GUI applications, and can create a window, but I don't know how to work with images. What commands can I use to display a picture in a window? Do you have any examples?
Thanks.
Maybe someone could giv me an example of how a Bitmap resource looks in the .rc file?
Thanks.
Thanks. This is the content of my .rc file:
...However, I get the following compilation error:Code:#include "resource.h"
#include "windows.h"
IDB_BITMAP1 BITMAP DISCARDABLE "Image.bmp"
Code:fatal error RC1004: unexpected end of file found
Forgot to include stdafx.h?
Thanks - I added it, but now I get:
Code:fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
What compiler are you using? In VC++ you should writeYou should include stdafx.h only if you are using precompiled headers and it include file is stdafx.h.Code:#include <windows.h>
Please post another code and header file of your program if possible.
This is related to the source and not to precompiled headers or stdafx.h.
So, posting your resource.h and the resource file might not be a bad idea.
Thanks,
I started with an empty project in the 'General' tab in VC++ 2008 Express. Here is the code:
Source:
Resource (I have no idea how to write a Bitmap resource):Code:#include <windows.h>
#include <stdafx.h>
#include "Resource.h"
HINSTANCE hInst;
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX WndCls;
static char szAppName[] = "BitmapIntro";
MSG Msg;
hInst = hInstance;
WndCls.cbSize = sizeof(WndCls);
WndCls.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
WndCls.lpfnWndProc = WindProcedure;
WndCls.cbClsExtra = 0;
WndCls.cbWndExtra = 0;
WndCls.hInstance = hInst;
WndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
WndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
WndCls.lpszMenuName = NULL;
WndCls.lpszClassName = szAppName;
WndCls.hIconSm = LoadIcon(hInstance, IDI_APPLICATION);
RegisterClassEx(&WndCls);
CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
szAppName,
"Bitmap",
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
while( GetMessage(&Msg, NULL, 0, 0) )
{
TranslateMessage(&Msg);
DispatchMessage( &Msg);
}
return static_cast<int>(Msg.wParam);
}
LRESULT CALLBACK WindProcedure(HWND hWnd, UINT Msg,
WPARAM wParam, LPARAM lParam)
{
HDC hDC, MemDCExercising;
PAINTSTRUCT Ps;
HBITMAP bmpExercising;
switch(Msg)
{
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &Ps);
bmpExercising = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1));
MemDCExercising = CreateCompatibleDC(hDC);
SelectObject(MemDCExercising, bmpExercising);
BitBlt(hDC, 10, 10, 450, 400, MemDCExercising, 0, 0, SRCCOPY);
DeleteDC(MemDCExercising);
DeleteObject(bmpExercising);
EndPaint(hWnd, &Ps);
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return 0;
}
Header:Code:#include "resource.h"
#include "windows.h"
IDB_BITMAP1 BITMAP DISCARDABLE "C:\Documents and Settings\XP\My Documents\My
Pictures\Image.bmp"
Thanks.Code:#include "windows.h"
#define IDB_BITMAP1 1000
putin .rc fileCode:#include <stdafx.h>
I've managed it another way - I think it may have been my resource editor program that wasn't set up properly, as I re-made my .rc file, and it gave me this:
Code:#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDB_BITMAP1 BITMAP "bitmap1.bmp"
http://i302.photobucket.com/albums/n...ageprogram.png
I can't follow link.
Provide that here please.
I don't know how to do that - how do I embed images on this forum? Here is another hyperlink:
Link
The next thing I am interested in doing is downloading an image from the net and displaying it in that frame. For example, if I want to download this image every time the program starts:
http://sohowww.nascom.nasa.gov/data/...024/latest.jpg
Is this hard t do?
Thanks.
I just don't.
So you can't load images yet and you already want to do another task related to images? Google is your friend. Do a little research and come back with a specific directed question about the problems you are having and we can offer more assistance.Quote:
The next thing I am interested in doing is downloading an image from the net and displaying it in that frame. For example, if I want to download this image every time the program starts: