i was trying to load a bmp image to a picture box control, using the windows api, but i couldn't find anything on how to do that. Could someone explain it to me? I was also wondering if i could load jpeg and png images, too.
i was trying to load a bmp image to a picture box control, using the windows api, but i couldn't find anything on how to do that. Could someone explain it to me? I was also wondering if i could load jpeg and png images, too.
i appreciate your suggestions, but i'm not asking about Qt or another framework.
-i have been working on win32 for weeks now and think its what i have been looking for. But if you insist that Qt is a better choice, i'll take a look at it.-
now do you have an answer for my first question?
Googling you can end up here
Don't know if there is explicitly a "Picture Box" in Win 32, but you can use any kind of window
thanks for your reply. do you know a way to load jpeg images too?
I was wondering why you were using Win32. I wasn't suggesting you to switch. That's none of my business.
It is merely the case that many people tend to use the wrong tool simply because they haven't been taught any better.
As to your question, no: I have no idea. And the reason is because I don't tend to use Win32, because it's a pain in the ass. There are far better gui alternatives out there, which are C++ to boot, and not pure C.
if you are insane and like programming which is akin to dentistry, continue with the win api, if you like fast portable, easy to implement, native c++ coding, use fltk
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
why does everyone think win32 is pain? isn't it flexible enough to allow doing anything the windows OS allows? or is there another reason? and what does "being portable" mean?
and thanks C_ntua, you seem to be the only one who has answered my question
Because it takes a lot of code to do simple things and it isn't trivial.
Of course the Win32 API allows you to do all the OS allows, because that's the thing--it is the complete functionality the OS allows you to use. But it isn't easy.
Portable simply means it allows the code to work on multiple platforms. Win32 API obviously only works on Windows.
Qt, for example, works on Windows, Mac, Linux, Symbian, Maemo. And it's simpler to use.
Win32 is more flexible, but flexibility comes at a price of more complexity. There is a line you have to draw between flexible and ease to use. I would choose Qt or any other framework over Win32 at any time because 1) the api is C, which pretty much means that it's very inflexible and difficult to use, and 2) frameworks are far easier than the win32 api.
and can i use opengl and directx with frameworks?
It would be doubtful, though there may be solutions for OpenGL with Qt.
However, you must understand that if you're writing games, you don't need a Gui framework; you just need a window and manipulating effects via DirectX or OpenGL.
If you're after animations and such using hard acceleration, it is possible using existing methods and such within frameworks. There is no need for DirectX/OpenGL there.
thanks for the explanation.
but i'm still waiting for someone who knows win32 and is able to answer the main question
so perhaps you would have been better posting in the windows programming section. For what its worth FLTK has full openGL support
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
Forger has most of the information on his guide, theForger's Win32 API Tutorial
I kinda went the resource/macro route which i kinda regret cause there's EXTREMELY little documentation on this and different compilers allow different tricks and blah, but the good part is that you can easily construct your resource files using programs such like ResEdit (or if you have VisualStudio use whatever it uses), anyhow here's some code to manage images and controls though resource/.rc file,
slimcore.c (where you catch window events and draw/call/display window)
simpleresource.rc (where you construct the visual parts)Code:/*----------------------------------------------------------*\ Slim TestCore v0.8 (just to get things rollin') LastUpd: 2011-03-11 CFGnotes: Link "comctl32" and include resource file. Credits: Julien Audo (.cpp & ResEdit) URL/NFO: http://www.codeproject.com/KB/cpp/resedit.aspx http://www.resedit.net \*----------------------------------------------------------*/ #include <windows.h> #include <commctrl.h> // Ah damnit! I was wacking it around and accidently hit the top so it just exploded all over me! BOOL CALLBACK AppDlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { SetClassLongPtr(hDlg,GCLP_HICON,(long)LoadIcon(0,IDI_APPLICATION)); return 1; } case WM_COMMAND: { switch(wParam) { case IDCANCEL: EndDialog(hDlg, 0); } } } return 0; } // Damn ketchup bottles! int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) { InitCommonControls(); DialogBoxParam(hInstance,(LPCTSTR)50,0,AppDlgProc,0); return 0; }
Hope you're not too confused, otherwise "theForger's" =)Code:// A simple Resource file #include <windows.h> #ifndef IDC_STATIC #define IDC_STATIC (-1) #endif LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL // Bitmap 70 BITMAP ".//location//of//your//bitmap.bmp" // Dialog 50 DIALOG 0, 0, 186, 95 STYLE DS_CENTER | DS_MODALFRAME | WS_POPUP FONT 8, "Ms Shell Dlg" { // if the compiler throws syntax-error replace "{" with "BEGIN" CONTROL 70, IDC_STATIC, WC_STATIC, SS_BITMAP, 52, 20, 77, 41 // image/control PUSHBUTTON "Exit", IDCANCEL, 150, 40, 35, 15 // A close button, program will also listen to "ESC" } // if the compiler throws syntax-error replace "}" with "END"