mercredi 27 juillet 2016

Sending text to button after adding image c++

I am able to add image to the button as background but later I want to add text to the button as "Weclome", I tried all possible ways using Settext, SendmessageA. please help

 #include <Windows.h>

int main()
{   MSG msg;
HWND hWnd = CreateWindow(TEXT("button"), TEXT("START"), WS_VISIBLE | WS_POPUP |  WS_CHILD | WS_TABSTOP | BS_BITMAP,
        250, 250, 500, 500, NULL, NULL, NULL,  NULL);
       HANDLE hImg = LoadImageW(NULL, L"Untitled.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_LOADFROMFILE);
SendMessageW(hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM) hImg);

SendMessageA(hWnd,WM_SETTEXT,0,(LPARAM)"Welcome");
//SendMessageW(hWnd, WM_SETTEXT, (WPARAM) 256,NULL);


         while (GetMessage(&msg, NULL, 0, 0))
    {
           ShowWindow(hWnd, SW_SHOW);
         UpdateWindow(hWnd);
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
 return (int) msg.wParam;
}

Aucun commentaire:

Enregistrer un commentaire