images, icons, and cursors, OH MY!

This is a discussion on images, icons, and cursors, OH MY! within the Windows Programming forums, part of the Platform Specific Boards category; hehehehe, i have drawn an image named "title.jpg" an icon named "dc.ico" and a cursor named "cursor1.cur", and i cant ...

  1. #1
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343

    images, icons, and cursors, OH MY!

    hehehehe, i have drawn an image named "title.jpg" an icon named "dc.ico" and a cursor named "cursor1.cur", and i cant find a single tutorial on how to load these images in without 500 lines of extra code. there was this one example in my book, but its a whole program dedicated to showing this one image and it has 500 lines of code! i dont want this...thee has got to be n easyer way, i just want the vertical image i drawn to appear on the left of my program at the coords x = 0, y = 0. as for the icon and cursor, how do i load thos, what do i put in my resource script, my header and what do i change
    Code:
    class.hIcon = LoadIcon (NULL, IDC_APPLICATION);
    class.hCursor = LoadCursor (NULL, IDI_ARROW);
    to? all 3 of the images are in a folder called "images", just thught you might want to know that.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Use LoadImage for loading your cursors, icons and bitmaps. With DevC++( mingw) forget jpegs; use a bitmap instead.

    For just about any other win32 compiler you can use OleLoadPicture for jpegs or get and use gdiplus. Search this board for more information on either of these (which you will not, as far as i'm aware, be able to use with mingw (DevC++)).

    edit: actually there may be third party image libraries available for use with mingw. Perhaps someone else will be able to provide more information on this.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Unregistered Leeman_s's Avatar
    Join Date
    Oct 2001
    Posts
    753
    here an example.

    Code:
    //script.rc
    
    #include "resource.h"
    
    IDR_MYMENU MENU
    BEGIN
        POPUP "&File"
    	BEGIN
    	    MENUITEM "E&xit", ID_FILE_EXIT
    	END
    END
    
    IDI_MYICON ICON "myicon.ico"
    IDB_BALL BITMAP "ball.bmp"
    Code:
    //resource.h
    
    #define IDR_MYMENU 101
    #define IDI_MYICON 102
    #define ID_FILE_EXIT 103
    #define IDB_BALL 104
    
    //i don't think you need all this stuff below but just put it in
    #ifdef APSTUDIO_INVOKED
    #ifndef APSTUDIO_READONLY_SYMBOLS
    #define _APS_NEXT_RESOURCE_VALUE        103
    #define _APS_NEXT_COMMAND_VALUE         40004
    #define _APS_NEXT_CONTROL_VALUE         1000
    #define _APS_NEXT_SYMED_VALUE           101
    #endif
    #endif
    Code:
    //main.cpp
    
    //......
    case WM_CREATE:
    		{
    			BITMAP bm;
    			HBITMAP Ball = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BALL));
    			HBITMAP BallMask = CreateBitmapMask(Ball, RGB(255,0,255));
    			GetObject(Ball, sizeof(bm), &bm);
    
    			ball.width = bm.bmWidth;
    			ball.height= bm.bmHeight;
    			ball.dx = 1;
    			ball.dy = 1;
    			ball.lastx = 4;
    			ball.lasty = 4;
    			ball.x = 5;
    			ball.y = 5;
    			ball.speed = 1;
    		}
    		break;
    //.....
    
    wc.lpszMenuName = MAKEINTRESOURCE(IDR_MYMENU);
    wc.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
    wc.hIconSm = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MYICON));
    wc.hCursor = LoadCursor(NULL, IDC_ARROW); //make a cursor just the same as the other resources i showed an example with
    and there you have it, any questions?

  4. #4
    Emotionally Unstable DarkViper's Avatar
    Join Date
    Oct 2002
    Posts
    343
    yeah, when i tried to get my bitmap to show, it gave me alot of errors. saying that Title.width = bm.bmWidth was unarguable. ?!?! im like, wtf?

    but the cursor works and so does the icon, and for that i think you. those were the vital things.

    uhh...how do i make the cursor change to another custom cursor when it goes over an Edit field, actually you know what, speaking of the edit field, forget the cusor thing, thats not important right now, but how do i change the total amount of text an edit field can have? and can you give me an example the same way you did that is what i understand.
    ~DJ DarkViper signing out
    ----------------------------------------
    My Site:
    Black Jaguar Studios

    Languages:
    Fluent English, Starter German, HTML, Javascript, Actionscript, Intermediate PHP

    Verteran Despiser of: ASP, Java, BASIC, Pascal, Cobalt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to make icons
    By stallion in forum Windows Programming
    Replies: 9
    Last Post: 01-29-2003, 10:29 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21