Thread: c++ GUI CONTROL

Results 1 to 4 of 4
  1. #1
    leonjun16's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Posts
    9
    Reputation
    10
    Thanks
    0

    c++ GUI CONTROL

    Code:
    LRESULT CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
        HWND cboShutdown_After;
        HWND cboTimer;
        cboShutdown_After = GetDlgItem(hwndDlg, IDD_Shutdown_After_CBO);
        cboTimer = GetDlgItem(hwndDlg, IDD_Timer_CBO);
        const char *Shutdown_After[3] = { "(Choose your process)","Shutdown After","Restart After" };
        const char *Timer[6]={"(Select the time to process)" ,"Now", "5 mins", "15 mins", "30 mins", "1 hour"};
        int Sel1 = SendMessage(cboShutdown_After, CB_GETCURSEL, 0, 0);
        int Sel2 = SendMessage(cboTimer, CB_GETCURSEL, 0, 0);
    
        switch(uMsg)
        {
            case WM_INITDIALOG:
    
                cboShutdown_After = GetDlgItem(hwndDlg, IDD_Shutdown_After_CBO);
                for(int Count = 0; Count < 3; Count++)
                {
                    SendMessage(cboShutdown_After,
                               CB_ADDSTRING,
                               0,
                               reinterpret_cast<LPARAM>((LPCTSTR)Shutdown_After[Count]));
                }
    
                cboTimer = GetDlgItem(hwndDlg, IDD_Timer_CBO);
                for(int Count2 = 0; Count2 < 6; Count2++)
                {
                    SendMessage(cboTimer,
                               CB_ADDSTRING,
                               0,
                               reinterpret_cast<LPARAM>((LPCTSTR)Timer[Count2]));
                }
    
                SendMessage(cboShutdown_After, CB_SETCURSEL, 0, 0);
                SendMessage(cboTimer, CB_SETCURSEL, 0, 0);
                break;
    
    
    
            case WM_CLOSE:
                EndDialog(hwndDlg, 0);
                return TRUE;
    
            case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                    case IDD_Shutdown_After_CBO: // If the combo box sent the message,
                    switch (HIWORD(wParam))
                    {
                        case 1:
                        switch(Sel1)
                        {
                            case 0:
                            MessageBox(NULL,"Please select an action.","Error",MB_ICONWARNING);
                            break;
    
                            case 1:
                            if(MessageBox(NULL,"You have choose Shutdown.\nConfirm?","Information",MB_ICONQUESTION | MB_OKCANCEL)==IDOK)
                            {
                                //Do shutdown here
                                MessageBox(NULL,"You have confirm for Shutdown.","Information",MB_ICONINFORMATION);
    
                            }
                            else
                            {
                                return 0;
                            }
                            break;
    
                            case 2:
                            if(MessageBox(NULL,"You have choose Restart.\nConfirm?","Information",MB_ICONQUESTION | MB_OKCANCEL)==IDOK)
                            {
                                //Do shutdown here
                                MessageBox(NULL,"You have confirm for Restart.","Information",MB_ICONINFORMATION);
                            }
                            else
                            {
                                return 0;
                            }
                            break;
                        }
                        break;
                    }
                    break;
    
            case IDD_Timer_CBO:
                switch (HIWORD(wParam))
                {
                    case 1:
                    switch(Sel2)
                    {
                        case 0:
                        MessageBox(NULL,"Please select a time.","Error",MB_ICONWARNING);
                        break;
    
                        case 1:
                        MessageBox(NULL,"Press apply to perform the action immediately.","Information",MB_ICONINFORMATION);
                        break;
    
                        case 2:
                        MessageBox(NULL,"Press apply to perform the action after 5 minutes.","Information",MB_ICONINFORMATION);
                        break;
    
                        case 3:
                        MessageBox(NULL,"Press apply to perform the action after 15 minutes.","Information",MB_ICONINFORMATION);
                        break;
    
                        case 4:
                        MessageBox(NULL,"Press apply to perform the action 30 minutes.","Information",MB_ICONINFORMATION);
                        break;
    
                        case 5:
                        MessageBox(NULL,"Press apply to perform the action 1 hour.","Information",MB_ICONINFORMATION);
                        break;
                    }
                    break;
                }
                break;
    
            case IDC_BTN_QUIT:
                EndDialog(hwndDlg, 0);
                return TRUE;
    
            case IDC_BTN_APPLY:
                MessageBox(hwndDlg, "Thanks for using!", "Information", MB_ICONINFORMATION);
                return TRUE;
                   }
                   break;
    
    
        }
        return FALSE;
    }
    This is a part of code that i try to make a shutdown with timer. I have 2 combo box, one is for shutdown/restart selection, one is for time selection. What should I code to make user press the apply button to process the selected process with the timer in that two combo box? And what is the code for shutdown and restart? system("shutdown") is unusable.

    Please forgive my broken english
    Last edited by leonjun16; 09-03-2012 at 09:05 AM.
    THE MOST SCARIEST AND EXCITED PART IN CODING IS 【DEBUGGING】.

  2. #2
    giniyat101's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Location
    Not telling.
    Posts
    1,935
    Reputation
    130
    Thanks
    1,380
    My Mood
    Dead
    you may send CB_GETCURSEL to the combo box to check the selected item index
    and you may use ExitWindowsEx to shutdown/ restart


     



    [img]https://i43.photobucke*****m/albums/e367/DeteSting/Steam-update.gif[/img]

  3. #3
    leonjun16's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Posts
    9
    Reputation
    10
    Thanks
    0
    Quote Originally Posted by giniyat101 View Post
    you may send CB_GETCURSEL to the combo box to check the selected item index
    and you may use ExitWindowsEx to shutdown/ restart
    Thanks!! i use the CB_GETCURSEL and works perfectly! But the ExitWindowsEx is not working sadcase
    THE MOST SCARIEST AND EXCITED PART IN CODING IS 【DEBUGGING】.

  4. #4
    giniyat101's Avatar
    Join Date
    Sep 2011
    Gender
    male
    Location
    Not telling.
    Posts
    1,935
    Reputation
    130
    Thanks
    1,380
    My Mood
    Dead
    Quote Originally Posted by leonjun16 View Post
    Thanks!! i use the CB_GETCURSEL and works perfectly! But the ExitWindowsEx is not working sadcase
    try to set shutdown privilege

    see How to Shut Down the System (Windows)


     



    [img]https://i43.photobucke*****m/albums/e367/DeteSting/Steam-update.gif[/img]

  5. The Following User Says Thank You to giniyat101 For This Useful Post:

    leonjun16 (09-05-2012)

Similar Threads

  1. 10 Min Rellease Ztx Rc Control
    By ~claw~ in forum WarRock - International Hacks
    Replies: 16
    Last Post: 09-14-2007, 11:44 PM
  2. Ingame GUI
    By unseenss in forum WarRock - International Hacks
    Replies: 11
    Last Post: 07-25-2007, 07:02 AM
  3. can u control these pbbypass?
    By kanym in forum WarRock - International Hacks
    Replies: 4
    Last Post: 05-16-2007, 10:35 AM
  4. [TUTORIAL]How to control an airplane :p and ofcourse insert it
    By System79 in forum WarRock - International Hacks
    Replies: 8
    Last Post: 07-09-2006, 03:44 PM
  5. CBS Controls StarTrek
    By Dave84311 in forum SCI-FI
    Replies: 5
    Last Post: 01-22-2006, 11:18 PM