Click here to Skip to main content
15,889,877 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Protect executables and prevent end process Pin
Rajesh R Subramanian10-Nov-08 2:56
professionalRajesh R Subramanian10-Nov-08 2:56 
AnswerRe: Protect executables and prevent end process Pin
22491710-Nov-08 15:14
22491710-Nov-08 15:14 
GeneralRe: Protect executables and prevent end process Pin
jlkdaslkfjd30-Mar-11 15:54
jlkdaslkfjd30-Mar-11 15:54 
AnswerRe: Protect executables and prevent end process Pin
Hamid_RT10-Nov-08 4:04
Hamid_RT10-Nov-08 4:04 
AnswerRe: Protect executables and prevent end process Pin
KarstenK10-Nov-08 4:14
mveKarstenK10-Nov-08 4:14 
AnswerRe: Protect executables and prevent end process Pin
22491710-Nov-08 14:10
22491710-Nov-08 14:10 
QuestionUpdate the background of dialog box.. Pin
gothic_coder10-Nov-08 0:17
gothic_coder10-Nov-08 0:17 
AnswerRe: Update the background of dialog box.. Pin
gothic_coder10-Nov-08 0:18
gothic_coder10-Nov-08 0:18 
#include <windows.h>

struct
{
    WORD palVersion;
    WORD palNumEntries;
    PALETTEENTRY palPalEntry[12];

} palPalette =
{

    0x300,
    12,
    {
        {0xFF, 0x00, 0x00, PC_RESERVED},
        {0xC0, 0x40, 0x00, PC_RESERVED},
        {0x80, 0x80, 0x00, PC_RESERVED},
        {0x40, 0xC0, 0x00, PC_RESERVED},
        {0x00, 0xFF, 0x00, PC_RESERVED},
        {0x00, 0xC0, 0x40, PC_RESERVED},
        {0x00, 0x80, 0x80, PC_RESERVED},
        {0x00, 0x40, 0xC0, PC_RESERVED},
        {0x00, 0x00, 0xFF, PC_RESERVED},
        {0x40, 0x00, 0xC0, PC_RESERVED},
        {0x80, 0x00, 0x80, PC_RESERVED},
        {0xC0, 0x00, 0x40, PC_RESERVED}

    }
};

POINT pt12[12] =

{
    {0, 1000},
    {500, 866},
    {866, 500},
    {1000, 0},
    {866, -500},
    {500, -866},
    {0, -1000},
    {-500, -866},
    {-866, -500},
    {-1000, 0},
    {-866, 500},
    {-500, 866}

};

void Animate(HWND hwnd, HPALETTE hPalette)

{
    HDC hDC;
    PALETTEENTRY pe[12];
    HPALETTE hOldPal;
    static int nIndex;
    int i;

    for (i = 0; i < 12; i++)
        pe[i] = palPalette.palPalEntry[(i + nIndex) % 12];

    hDC = GetDC(hwnd);
    hOldPal = SelectPalette(hDC, hPalette, FALSE);
    RealizePalette(hDC);
    AnimatePalette(hPalette, 0, 12, pe);
    nIndex = (++nIndex) % 12;
    SelectPalette(hDC, hOldPal, FALSE);
    ReleaseDC(hwnd, hDC);

}

void DrawCircle(HWND hwnd, HPALETTE hPalette)

{
    HDC hDC;
    PAINTSTRUCT paintStruct;
    RECT rect;
    SIZE sizeO;
    POINT ptO;
    HPALETTE hOldPal;
    int i;

    hDC = BeginPaint(hwnd, &paintStruct);
    if (hDC != NULL)

    {

	    hOldPal = SelectPalette(hDC, hPalette, FALSE);
        RealizePalette(hDC);
        GetClientRect(hwnd, &rect);
        DPtoLP(hDC, (LPPOINT)&rect, 2);
        ptO.x = (rect.left + rect.right) / 2;
        ptO.y = (rect.top + rect.bottom) / 2;
        sizeO.cx = MulDiv((rect.right - rect.left), 2, 3);
        sizeO.cy = MulDiv((rect.bottom - rect.top), 2, 3);
        for (i = 0; i < 12; i++)
        {
            HBRUSH hbr;
            HBRUSH hbrOld;
            hbr = CreateSolidBrush(PALETTEINDEX(i));
            hbrOld = (HBRUSH)SelectObject(hDC, hbr);
            Ellipse(hDC,

                ptO.x + MulDiv(sizeO.cx, pt12[i].x - 259, 2000),
                ptO.y + MulDiv(sizeO.cy, pt12[i].y - 259, 2000),
                ptO.x + MulDiv(sizeO.cx, pt12[i].x + 259, 2000),
                ptO.y + MulDiv(sizeO.cy, pt12[i].y + 259, 2000)
            );

            SelectObject(hDC, hbrOld);
            DeleteObject(hbr);
        }

        SelectPalette(hDC, hOldPal, FALSE);
        EndPaint(hwnd, &paintStruct);
    }

}

LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg,

                         WPARAM wParam, LPARAM lParam)

{

    static HPALETTE hPalette;
    switch(uMsg)
    {
        case WM_CREATE:
            hPalette = CreatePalette((LPLOGPALETTE)&palPalette);
            break;

        case WM_PAINT:
            DrawCircle(hwnd, hPalette);
            break;

        case WM_TIMER:
	        Animate(hwnd, hPalette);
	        break;

        case WM_DESTROY:
            DeleteObject(hPalette);
            hPalette = NULL;
            PostQuitMessage(0);
            break;

        default:
            return DefWindowProc(hwnd, uMsg, wParam, lParam);

    }
    return 0;

}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,

                                        LPSTR d3, int nCmdShow)

{
    MSG msg;
    HWND hwnd;
    WNDCLASS wndClass;

    if (hPrevInstance == NULL)
    {
        memset(&wndClass, 0, sizeof(wndClass));
        
		wndClass.style         = CS_HREDRAW | CS_VREDRAW ;
		wndClass.lpfnWndProc   = WndProc ;
		wndClass.cbClsExtra    = 0 ;
		wndClass.cbWndExtra    = 0 ;
		wndClass.hInstance     = hInstance ;
		wndClass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
		wndClass.hbrBackground = (HBRUSH) GetStockObject (HOLLOW_BRUSH ) ;
		wndClass.lpszMenuName  = NULL ;
		wndClass.lpszClassName = "HELLO";
        
		if (!RegisterClass(&wndClass)) return FALSE;
    }


    hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
						  "HELLO",  						// window class name
						  NULL,								// window caption
						  WS_POPUP,							// window style
						  10,								// initial x position
						  10,								// initial y position
						  200,								// initial x size
						  200,								// initial y size
						  NULL,								// parent window handle
						  NULL,								// window menu handle
						  hInstance,						// program instance handle
						  NULL) ;							// creation parameters

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
    SetTimer(hwnd, 1, 200, NULL);
    while (GetMessage(&msg, NULL, 0, 0))
        DispatchMessage(&msg);

    KillTimer(hwnd, 1);
    return msg.wParam;

}
</windows.h>

GeneralRe: Update the background of dialog box.. Pin
enhzflep10-Nov-08 1:34
enhzflep10-Nov-08 1:34 
GeneralRe: Update the background of dialog box.. Pin
gothic_coder10-Nov-08 2:13
gothic_coder10-Nov-08 2:13 
GeneralRe: Update the background of dialog box.. Pin
enhzflep10-Nov-08 2:24
enhzflep10-Nov-08 2:24 
GeneralRe: Update the background of dialog box.. Pin
gothic_coder10-Nov-08 4:02
gothic_coder10-Nov-08 4:02 
GeneralRe: Update the background of dialog box.. Pin
enhzflep10-Nov-08 14:18
enhzflep10-Nov-08 14:18 
GeneralRe: Update the background of dialog box.. Pin
gothic_coder10-Nov-08 23:09
gothic_coder10-Nov-08 23:09 
QuestionXML Skinnable Dialogs or Vista or XP style dialogs Pin
Sreekanth Muralidharan9-Nov-08 23:26
Sreekanth Muralidharan9-Nov-08 23:26 
AnswerRe: XML Skinnable Dialogs or Vista or XP style dialogs Pin
Ahmed Charfeddine9-Nov-08 23:49
Ahmed Charfeddine9-Nov-08 23:49 
Questionreading astring value unto a DWORD [SOLVED] Pin
Ahmed Charfeddine9-Nov-08 23:11
Ahmed Charfeddine9-Nov-08 23:11 
AnswerRe: reading astring value unto a DWORD Pin
chandu0049-Nov-08 23:14
chandu0049-Nov-08 23:14 
GeneralRe: reading astring value unto a DWORD Pin
Ahmed Charfeddine9-Nov-08 23:44
Ahmed Charfeddine9-Nov-08 23:44 
Questionhow to store a value at the specified location in RAM. Pin
chandu0049-Nov-08 23:06
chandu0049-Nov-08 23:06 
AnswerRe: how to store a value at the specified location in RAM. Pin
CPallini9-Nov-08 23:24
mveCPallini9-Nov-08 23:24 
GeneralRe: how to store a value at the specified location in RAM. Pin
chandu0049-Nov-08 23:38
chandu0049-Nov-08 23:38 
QuestionRe: how to store a value at the specified location in RAM. Pin
CPallini9-Nov-08 23:56
mveCPallini9-Nov-08 23:56 
AnswerRe: how to store a value at the specified location in RAM. Pin
chandu00410-Nov-08 0:20
chandu00410-Nov-08 0:20 
AnswerRe: how to store a value at the specified location in RAM. Pin
Iain Clarke, Warrior Programmer9-Nov-08 23:52
Iain Clarke, Warrior Programmer9-Nov-08 23:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.