Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: getColor()

  1. #11
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Wow, I was looking at the wsprintf(), I had a hard time understanding what was going on here:
    Code:
    #%.6X R:%.3i G:%.3i B:%.3i
    

    But I think I finally got it. I wasn't following the ". number system" but that's the amount of characters for the color which makes sense since the hex value is 6 alpha numeric characters and the RGB values are 3. Yay I learned something.

    Code:
    
    
    Code:
    FormatColor(0);
    

    Hmm why are you passing 0 here? I'm assuming 0 = black :S (this is in reference to wm_create).

    I will try this out at home and see how it looks. Nice job.
    BTW, is the while loop what's effing it up from working for me? I feel soooo stupid :P But damn I was close.

  2. #12

    Default

    Quote Originally Posted by James View Post
    Wow, I was looking at the wsprintf(), I had a hard time understanding what was going on here:
    Code:
    #%.6X R:%.3i G:%.3i B:%.3i
    

    But I think I finally got it. I wasn't following the ". number system" but that's the amount of characters for the color which makes sense since the hex value is 6 alpha numeric characters and the RGB values are 3. Yay I learned something.

    Code:
    
    
    Code:
    FormatColor(0);
    

    Hmm why are you passing 0 here? I'm assuming 0 = black :S (this is in reference to wm_create).

    I will try this out at home and see how it looks. Nice job.
    BTW, is the while loop what's effing it up from working for me? I feel soooo stupid :P But damn I was close.
    .3 means that the number will be padded with zero's, until length of 3 is reached, so 5 will become 005
    Because the font is Courier, the text will not jump around
    The FormatColor(0) is simply to get a valid string, to calculate the needed window size

  3. #13
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Your program worked very nicely. I was jealous as usual haha, I took out the while loop, but am still having problems coloring the damn window errr. I'll have to take a deeper look at my app to figure out why it's not working right.

  4. #14
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Hmm, perhaps someone can test this, but for some reason, if I hover over something at the top of any window, it doesn't color the entire screen :S

    PHP Code:
    // getColorWin32.cpp : Defines the entry point for the application.
    //

    #include "stdafx.h"
    #include "colorGUI.h"
    #include <windows.h> 
    #include <iostream>

    #define MAX_LOADSTRING 100

    // Global Variables:
    HINSTANCE hInst;

    LRESULT CALLBACK    WndProc(HWNDUINTWPARAMLPARAM);

    void DrawFilledRect (HDC hDCRECTrCOLORREF rgbFrame)
    {
        
    HBRUSH hBrush;
        
    HDC hColor;
        
    COLORREF myColor;

        
    GetCursorPos((LPPOINT)&r);
        
    hColor GetDC(NULL);
        
    myColor GetPixel(hColorr.leftr.top);
        
    hBrush CreateSolidBrush (myColor);
        
    FillRect(hDC, &rhBrush);
        
    DeleteObject (hBrush);

        
    hBrush CreateSolidBrush (rgbFrame);
        
    FrameRect (hDC, &rhBrush);
        
    DeleteObject (hBrush);
    }

    void CenterWindow(HWND hwnd
    {
        
    RECT rc;

        
    GetWindowRect(hwnd,&rc);

        
    int nWidth rc.right rc.left;
        
    int nHeight rc.bottom rc.top;

        
    int X = ((int) GetSystemMetrics(SM_CXFULLSCREEN) - nWidth) /2;       // center window horizontally
        
    int Y = ((int) GetSystemMetrics(SM_CYFULLSCREEN) - nHeight) /2;      // and vertically

        
    MoveWindow(hwnd,X,Y,nWidth,nHeight,TRUE);
    }

    int APIENTRY _tWinMain(HINSTANCE hInstanceHINSTANCE hPrevInstanceLPTSTR lpCmdLineint nCmdShow)
    {
        
    MSG msg;
        
    char szWindowClass[] = "test_WindowClass";

        
    WNDCLASSEX wcex = {0};
            
    wcex.cbSize              sizeof(WNDCLASSEX);
            
    wcex.style            0;
            
    wcex.lpfnWndProc      WndProc;
            
    wcex.hInstance        hInstance;
            
    wcex.hCursor          LoadCursorNULLIDC_ARROW );
            
    wcex.lpszClassName    szWindowClass;
            
    wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW 1);
        
    RegisterClassEx( &wcex );

        
    HWND hWnd CreateWindowEx(0szWindowClass"Testing"SS_OWNERDRAW|WS_VISIBLE|WS_OVERLAPPEDWINDOW0,0,400,200,NULL,NULL,hInstance,NULL);
        
        if (!
    hWnd)
        {
            return 
    FALSE;
        }

        
    CenterWindow(hWnd);
        
    UpdateWindow(hWnd);

        while (
    GetMessage(&msgNULL00))
        {
            
    TranslateMessage(&msg);
            
    DispatchMessage(&msg);
        }
        return (int) 
    msg.wParam;
    }

    LRESULT CALLBACK WndProc(HWND hWndUINT messageWPARAM wParamLPARAM lParam)
    {    
        
    PAINTSTRUCT ps;
        
    HDC hdc;
        
    RECT rec = {0};

        switch (
    message)
        {    
            case 
    WM_CREATE:
            {
                
    SetTimerhWnd0x123USER_TIMER_MINIMUMNULL );
            }
            break;

            case 
    WM_PAINT:
            {
                
    hdc BeginPaint(hWnd, &ps);
                
    DrawFilledRect(hdcrec000000);
                
    EndPaint(hWnd, &ps);
            }
            break;

            case 
    WM_DESTROY:
                
    PostQuitMessage(0);
            break;

            case 
    WM_TIMER:
            {
                
    InvalidateRect (hWndNULLTRUE);
                
    UpdateWindow(hWnd);
            }
            break;

            default:
                return 
    DefWindowProc(hWndmessagewParamlParam);
        }
        return 
    0;


  5. #15

    Default

    Code:
    hdc = BeginPaint(hWnd, &ps);
    DrawFilledRect(hdc, rec, 000000);
    EndPaint(hWnd, &ps);
    you did not initialize rec

  6. #16
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    I took a break from the code and just wanted to finish it up finally.
    Currently I have a working app I'm semi satisfied with, however there are 2 things that I would like to fix still.
    1. What's up with the constant flickering???? errrr
    2. What is wrong with this line:
    Code:
    sprintf_s( szBuffer, sizeof( szBuffer ), "My Color is: \nHex: #%.6X \nDecimal(RGB): %.3i %.3i %.3i", myColor, red, green, blue);
    It should print out like this:
    Code:
    My Color is:
    Hex: #FFFFFF
    Decimal(RGB): 255 255 255
    instead it prints it out on 1 line. It doesn't seem to take the "\n" character that should put it on a new line. What gives?

    And here is my latest source
    PHP Code:
    // getColorWin32.cpp : Defines the entry point for the application.
    //

    #include "stdafx.h"
    #include "colorGUI.h"
    #include <windows.h> 
    #include <iostream>

    #define MAX_LOADSTRING 100

    // Global Variables:
    HINSTANCE hInst;
    LRESULT CALLBACK    WndProc(HWNDUINTWPARAMLPARAM);

    RECT initRecArea(int leftint topint widthint height)
    {
        
    RECT rec = {lefttopwidthheight};
        return 
    rec;
    }

    void DrawText (HDC hDCRECTr)
    {
        
    int red,green,blue;
        
    char szBuffer[512];
        
    DWORD textColor;
        
    HFONT hFont;
        
    HDC hColor;
        
    COLORREF myColor;
        
    RECT rec initRecArea(rec.leftrec.top00);

        
    /*
            This code grabs the color anywhere on the desktop and assigns it to myColor()
        */
        
    GetCursorPos((LPPOINT)&r);
        
    hColor GetDC(NULL);
        
    myColor GetPixel(hColorr.leftr.top);

        
    /*
            Create our text
        */
        
    hFont CreateFont(16,0,0,0,FW_SEMIBOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,CLEARTYPE_QUALITY,DEFAULT_PITCH,FF_DONTCARE );
         
    SelectObjecthDChFont );
        
    textColor RGB(255-GetRValue(myColor), 255-GetGValue(myColor), 255-GetBValue(myColor));

        
    red GetRValue(myColor);
        
    green GetGValue(myColor);
        
    blue GetBValue(myColor);

        
    sprintf_sszBuffersizeofszBuffer ), "My Color is: \nHex: #%.6X \nDecimal(RGB): %.3i %.3i %.3i"myColorredgreenblue);
        
    SetBkModehDCTRANSPARENT );
        
    SetTextColorhDCtextColor );
        
    TextOutAhDC00szBufferstrlen(szBuffer));
    }

    void DrawFilledRect (HDC hDCRECTr)
    {
        
    HBRUSH hBrush;
        
    HDC hColor;
        
    COLORREF myColor;
        
    RECT rec initRecArea(rec.leftrec.top00);

        
    /*
            This code grabs the color anywhere on the desktop and assigns it to myColor()
        */
        
    GetCursorPos((LPPOINT)&r);
        
    hColor GetDC(NULL);
        
    myColor GetPixel(hColorr.leftr.top);

        
    /*
            We take our color from above and color the rectangle
        */
        
    hBrush CreateSolidBrush (myColor);
        
    FillRect(hDC, &rechBrush);
        
    DeleteObject (hBrush);
    }

    void CenterWindow(HWND hwnd
    {
        
    /*
            Center our Dialog on the monitor
        */
        
    RECT rc;

        
    GetWindowRect(hwnd,&rc);

        
    int nWidth rc.right rc.left;
        
    int nHeight rc.bottom rc.top;

        
    int X = ((int) GetSystemMetrics(SM_CXFULLSCREEN) - nWidth) /2;       // center window horizontally
        
    int Y = ((int) GetSystemMetrics(SM_CYFULLSCREEN) - nHeight) /2;      // and vertically

        
    MoveWindow(hwnd,X,Y,nWidth,nHeight,TRUE);
    }

    void RefreshWnd (HWND hWndRECTpArea)
    {
        
    /*
            Refresh our dialog
        */
        
    CenterWindow(hWnd);
        
    GetClientRecthWndpArea );
        
    InvalidateRect (hWndpAreaTRUE);
        
    UpdateWindow (hWnd);
    }

    int APIENTRY _tWinMain(HINSTANCE hInstanceHINSTANCE hPrevInstanceLPTSTR lpCmdLineint nCmdShow)
    {
        
    MSG msg;
        
    char szWindowClass[] = "test_WindowClass";

        
    WNDCLASSEX wcex = {0};
            
    wcex.cbSize              sizeof(WNDCLASSEX);
            
    wcex.style            0;
            
    wcex.lpfnWndProc      WndProc;
            
    wcex.hInstance        hInstance;
            
    wcex.hCursor          LoadCursorNULLIDC_ARROW );
            
    wcex.lpszClassName    szWindowClass;
            
    wcex.hbrBackground      = (HBRUSH)(COLOR_WINDOW 1);
        
    RegisterClassEx( &wcex );

        
    HWND hWnd CreateWindowEx(0szWindowClass"Testing"SS_OWNERDRAW|WS_VISIBLE|WS_OVERLAPPEDWINDOW0,0,400,100,NULL,NULL,hInstance,NULL);
        
        if (!
    hWnd)
        {
            return 
    FALSE;
        }

        
    RefreshWnd (hWndNULL);

        while (
    GetMessage(&msgNULL00))
        {
            
    TranslateMessage(&msg);
            
    DispatchMessage(&msg);
        }
        return (int) 
    msg.wParam;
    }

    LRESULT CALLBACK WndProc(HWND hWndUINT messageWPARAM wParamLPARAM lParam)
    {    
        
    PAINTSTRUCT ps;
        
    HDC hdc;
        
    RECT rec = {0};

        switch (
    message)
        {    
            case 
    WM_CREATE:
            {
                
    SetTimerhWndNULLUSER_TIMER_MINIMUMNULL );
            }
            break;

            case 
    WM_PAINT:
            {
                
    hdc BeginPaint(hWnd, &ps);
                
    GetClientRecthWnd, &rec );
                
    AdjustWindowRectEx( &recWS_OVERLAPPED WS_CAPTION WS_SYSMENUFALSENULL );
                
    DrawFilledRect(hdcrec);
                
    DrawText(hdcrec);
                
    EndPaint(hWnd, &ps);
            }
            break;

            case 
    WM_DESTROY:
            {
                
    PostQuitMessage(0);
            }
            break;

            case 
    WM_TIMER:
            {
                
    RefreshWnd(hWnd, &rec);
            }
            break;

            default:
                return 
    DefWindowProc(hWndmessagewParamlParam);
        }
        return 
    0;


  7. #17
    Administrator JoTo's Avatar
    Join Date
    May 2010
    Location
    www.scapp.net
    Posts
    1,953

    Default

    To elimate flickering you need to enable double buffering for the part that you are painting too, e.g. window or a particular control

  8. #18
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Found some links, others may find these useful
    http://tek-tips.com/viewthread.cfm?qid=1597294&page=2
    http://www.dreamincode.net/forums/to...-evil-flicker/
    http://www.catch22.net/tuts/flicker
    http://www.gamedev.net/topic/411559-...ble-buffering/

    PHP Code:
    #include <windows.h>

    LPWSTR window_class_name = { L"my flicker window" };
    HFONT font;

    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Main window drawing callback procedure
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    LRESULT WINAPI main_window_proc(HWND window_handleUINT message
                                    
    WPARAM wparamLPARAM lparam) {
        switch ( 
    message ) {
            case 
    WM_PAINT:
            {
                
    PAINTSTRUCT paint_structure;
                
    RECT client_rect;
                
    HDC paint_device_contextpaint_dc;
                
    HBITMAP bitmap;

                
    paint_device_context BeginPaint(window_handle, &paint_structure);
                
    paint_dc CreateCompatibleDC(paint_device_context);
                
    GetClientRect(window_handle, &client_rect);
                
    bitmap CreateCompatibleBitmap(paint_dc,
                                                
    client_rect.right-client_rect.left,
                                                
    client_rect.bottom-client_rect.top);
                
    HGDIOBJ old_bitmap SelectObject(paint_dcbitmap);
                
    FillRect(paint_dc, &paint_structure.rcPaint,
                         (
    HBRUSH)GetStockObject(WHITE_BRUSH));
                
    HGDIOBJ old_font SelectObject(paint_dcfont);
                
    DrawText(paint_dcL"Hello"5, &client_rect
                         
    DT_CENTER|DT_VCENTER|DT_SINGLELINE);
                
    SelectObject(paint_dcold_font);
                
    BitBlt(paint_device_context00
                       
    client_rect.right-client_rect.left,
                       
    client_rect.bottom-client_rect.top,
                       
    paint_dc00SRCCOPY);
                
    SelectObject(paint_dcold_bitmap);
                
    DeleteObject(bitmap); 
                
    DeleteDC(paint_dc);
                
    EndPaint(window_handle, &paint_structure);
                return 
    0;
            }
            case 
    WM_ERASEBKGND:
            {
                return 
    TRUE;
            }
            case 
    WM_SIZE:
            {
                
    InvalidateRect(window_handleNULLTRUE);
                return 
    0;
            }
            case 
    WM_CLOSE:
            {
                
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                // The user wants to close the window
                //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

                
    PostQuitMessage(0);
                return 
    0;
            }
        }
        return 
    DefWindowProc(window_handlemessagewparamlparam);
    }

    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Windows main entry point
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    int WINAPI wWinMain(HINSTANCE instance_handleHINSTANCELPWSTRINT) {
        
    HCURSOR cursor_arrow LoadCursor(instance_handleIDC_ARROW);
        
    WNDCLASS window_class = { CS_OWNDCmain_window_proc00
                                  
    instance_handleNULL
                                  
    cursor_arrow
                                  
    NULLNULL
                                  
    window_class_name };

        
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // Create a standard frame window
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        
    RegisterClass(&window_class);
        
    HWND window_handle CreateWindowEx(WS_EX_WINDOWEDGE|WS_EX_CLIENTEDGE
                                            
    window_class_name
                                            
    L"My Flicker Window",
                                            
    WS_OVERLAPPEDWINDOWCW_USEDEFAULT,
                                            
    CW_USEDEFAULTCW_USEDEFAULT
                                            
    CW_USEDEFAULTNULLNULL,
                                            
    instance_handleNULL);

        
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // Create a font to display the text in our rectangle
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        
    font CreateFont(200000FW_BOLDFALSEFALSE,
                          
    FALSEANSI_CHARSETOUT_TT_PRECISCLIP_TT_ALWAYS,
                          
    PROOF_QUALITYFF_SWISSL"Arial");

        
    ShowWindow(window_handleSW_SHOW);
        
    UpdateWindow(window_handle);

        
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // Window message loop
        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

        
    MSG window_message;
        while ( 
    GetMessage(&window_messageNULL00) ) {
            
    TranslateMessage(&window_message);
            
    DispatchMessage(&window_message);
        }
        
    UnregisterClass(window_class_nameinstance_handle);
        return 
    0;

    I fixed the background flickering, but now the font is flickering haha. I think I need to use SelectObject(). Thanks Joto!

  9. #19

    Default

    use drawtext for newlines,
    and do not create a new font object every time you draw (only at program startup)

  10. #20
    Administrator James's Avatar
    Join Date
    May 2010
    Location
    on the intraweb
    Posts
    3,180

    Default

    Took over half a year, but I finally got the final product yay!!!

    PHP Code:
    #include <iostream>
    #include <windows.h>
    #include <stdio.h>
    #include <tchar.h>

    //Window Handles
    HWND hWnd;

    int screenWidth 0;
    int screenHeight 0;

    //Center Window
    VOID CenterWindow(HWND hwndHWND hwndParentint Widthint Height)
    {
        
    /* Variables */
        
    RECT rc;
     
        
    /* If Parent Window Is Set As Null, Get The Desktop Window */
        
    if(hwndParent == NULL)
        {
            
    hwndParent GetDesktopWindow();
        }
     
        
    /* Get Parent Client Area Measurements */
        
    GetClientRect(hwndParent, &rc);
     
        
    /* Center The Window */
        
    MoveWindow(hwnd, (rc.right rc.left Width) / 2, (rc.bottom rc.top Height) / 2WidthHeightTRUE);
     
        return;
    }

    bool isRunning()
    {
        
    //This checks if the process is already running so you don't have multiple instances running.
        
    HANDLE handle CreateMutex(NULLtrue"myColor");
        if(
    GetLastError() != ERROR_SUCCESS)
        {
            
    MessageBox(0"Process is already running""Warning"MB_ICONWARNING);
            return 
    false;
        }
        else
            return 
    true;
    }

    RECT initRecArea(int leftint topint widthint height

        
    RECT rec = {lefttopwidthheight}; 
        return 
    rec


    COLORREF getColor(void
    {
        
    POINT p;
        
    COLORREF color;
        
    HDC hDC GetDC(NULL);
        
    BOOL b;
     
        
    // Get the device context for the screen
        
    if (hDC == NULL)
        {
            
    MessageBoxA(0"Device context can't be found!""Error"MB_OK MB_ICONERROR);
            return 
    0;
        }
     
        
    // Get the current cursor position
        
    GetCursorPos(&p);
        if (!
    b)
        {
            
    MessageBoxA(0"Can't get the cursor position!""Error"MB_OK MB_ICONERROR);
            return 
    0;
        }
     
        
    // Retrieve the color at that position
        
    color GetPixel(hDCp.xp.y);
     
        
    // Release the device context again
        
    ReleaseDC(GetDesktopWindow(), hDC);
     
        return 
    color;
    }

    void DrawStuff(HWND hWndHDC hDCRECTrc

        
    //Get the rectangle of our screen & calculate the width & height
        
    RECT rec initRecArea(rc.leftrc.topscreenWidthscreenHeight);
        
    GetClientRect(hWnd, &rec);
        
    screenWidth = (rec.right rec.left);
        
    screenHeight =  (rec.bottom rec.top);

        
    HDC memDC CreateCompatibleDC(hDC);
        
    HBITMAP hMemBmp CreateCompatibleBitmap(hDCscreenWidthscreenHeight);
        
    HBITMAP hOldBmp = (HBITMAP)SelectObject(memDChMemBmp);

        
    POINT p;
        
    BOOL b1 GetCursorPos(&p);
        
    COLORREF myColor;
        
    char szBuffer[512];

        
    // Get the device context for the screen
        
    if (hDC == NULL)
        {
            
    MessageBoxA(0"Device context can't be found!""Error"MB_OK MB_ICONERROR);
        }

        
    myColor getColor();        

        
    //Color the background to myColor
        
    HBRUSH hBrush CreateSolidBrush(myColor);
        
    FillRect(memDC, &rec, (HBRUSH)hBrush);
        
    DeleteObject((HBRUSH)hBrush);
        
        
    // Draw Buffer into screen
        
    BitBlt(hDC00screenWidthscreenHeightmemDC00SRCCOPY);

        
    //Draw the text onto screen
        
    sprintf_sszBuffersizeofszBuffer ), "My Color is: \nHex: #%X \nDecimal(RGB): %i %i %i"myColorGetRValue(myColor), GetGValue(myColor), GetBValue(myColor));
        
    SetBkMode(hDCTRANSPARENT);
        
    SetTextColor(hDCRGB((255 GetRValue(myColor)), (255 GetGValue(myColor)), (255 GetBValue(myColor))));
        
    SetRect(&recrec.leftrec.top/2rec.rightrec.bottom/2);
        
    DrawText(hDCszBuffer, (strlen(szBuffer)), &recDT_CENTER DT_VCENTER DT_NOCLIP );

        
    //Free Resources
        
    SelectObject(memDChOldBmp);
        
    DeleteObject(hMemBmp);
        
    DeleteDC(memDC);
    }  

    LRESULT CALLBACK WndProc(HWND hWndUINT messageWPARAM wParamLPARAM lParam)
    {
        
    PAINTSTRUCT ps;
        
    HDC hdc;
        
    RECT rc = {0};

        switch (
    message)
        {
            case 
    WM_ERASEBKGND:
            {
                return 
    TRUE;
            }
            break;

            case 
    WM_PAINT:
            {
                
    hdc BeginPaint(hWnd, &ps);            

                
    // TODO: Add any drawing code here...
                
    DrawStuff(hWndhdcrc);
                
    ReleaseDC(hWndhdc);

                
    EndPaint(hWnd, &ps);
            }
            break;

            case 
    WM_CREATE:
            {
                
    SetTimerhWndNULLUSER_TIMER_MINIMUMNULL );
            }
            break;

            case 
    WM_TIMER:
            {
                
    GetClientRecthWnd, &rc );
                
    InvalidateRecthWnd, &rcTRUE );
            }
            break;

            case 
    WM_KEYDOWN:
            {
                 if(
    wParam == VK_ESCAPE
                 {
                     
    int ret MessageBox(NULLTEXT("Are you sure to quit?"), TEXT("Message"), MB_OKCANCEL);
                     
                     if(
    ret == IDOK
                     {
                         
    SendMessage(hWndWM_CLOSE00);
                     }
                 }
            }
            break;

            case 
    WM_DESTROY:
                
    PostQuitMessage(0);
            break;

            default:
                return 
    DefWindowProc(hWndmessagewParamlParam);
        }
        return 
    0;
    }

    int APIENTRY WinMainHINSTANCE hInstanceHINSTANCE hPrevInstanceLPSTR lpCmdLineint nCmdShow )
    {
        
    //Check if this process is running
        
    if(isRunning() == false)
            return 
    0;
        
        
    char szWindowClass[] = "myColor";
        
    MSG msg;

        
    WNDCLASSEX wcex        = {0};
        
    wcex.cbSize            sizeof(WNDCLASSEX);
        
    wcex.style          CS_HREDRAW CS_VREDRAW;
        
    wcex.lpfnWndProc    WndProc;
        
    wcex.hInstance      hInstance;
        
    wcex.hCursor        LoadCursorNULLIDC_ARROW );
        
    wcex.hbrBackground    = (HBRUSH)GetStockObject(BLACK_BRUSH);
        
    wcex.lpszClassName  szWindowClass;
        
    wcex.hIcon            LoadIcon(NULLIDI_APPLICATION);
        
    wcex.hIconSm        LoadIcon(NULLIDI_APPLICATION);
        
    RegisterClassEx( &wcex );

                
        
    //Main Application Window
        
    hWnd CreateWindowEx(0szWindowClass""WS_POPUPWINDOW WS_CAPTION WS_MAXIMIZEBOX00400200NULLNULLhInstanceNULL);
        
        
    // Do stuff here

        //End

        
    if(!hWnd)
        {
            return 
    FALSE;
        }

        
    //Activate our Main Window
        
    CenterWindow(hWndNULL400200);
        
    ShowWindow(hWndnCmdShow);
        
    UpdateWindow(hWnd);

        while(
    GetMessage(&msgNULL00))
        {
            
    TranslateMessage( &msg );
            
    DispatchMessage( &msg );
        }

        return (int) 
    msg.wParam;


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •