Thread: Please Help with code(attached) Please

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    Question Please Help with code(attached) Please

    Hi. I am trying to write this program for a project at school. It is a windows program that I am trying to make into a word processor. I have the main section done, but I can't figure how to display a bmp (the one in my script.rc) in a dialog box. If someone could tell me what to do or attach a reply with code, I would really appreciate it. Thanks a million.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Run a search as this gets asked quite a lot.

    In your code
    Code:
    HDC hdc, hdcMem ; //no init here for hdc
    HINSTANCE hInstance ; 
    PAINTSTRUCT ps;
    BITMAP1=LoadBitmap(hInstance,  MAKEINTRESOURCE(102)); 
    
    GetObject(BITMAP1, sizeof(BITMAP1), &bitmap);
    cxSource=bitmap.bmWidth; //why do this if you are not going to use them?
    cySource=bitmap.bmHeight; 
    	
    hdcMem=CreateCompatibleDC(hdc); //What is hdc?
    SelectObject(hdcMem, BITMAP1); 
    BitBlt(hdc, 1, 1, 50, 50, hdcMem, 0, 0, SRCCOPY);
    What value does hdc have that you are creating a HDC compatible with it?

    Try
    Code:
    HWND hWnd_Object_To_Paint;//get this HWND with GetDlgItem() ect
    
    hdc=GetDC(hWnd_Object_To_Paint);
    //your stuff
    ReleaseDC(hdc);
    Of course this will only draw it once. When the window needs to be repainted and a WM_PAINT msg is sent you will need to redraw it.
    For this I would recomend a framebufferDC and screenDC system.
    That is all drawing is done to one HDC, the framebuffer. AFTER all the drawing is done the FrameBufferDC is 'copied' [BltBit()] to the screenDC and a paint msg called for with UpdateWindow() or InvalidateRect().
    All painting is done with the screenDC. In the paint function the minimum of work is done to ensure it is fast.
    Also you must ensure like any memory you create that you free it before using the same handle again or exiting the app.
    As I said run a search for more code on this.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed