dialog work so far, has a gdi resource leak
This commit is contained in:
@@ -11,49 +11,125 @@
|
|||||||
/* Headers */
|
/* Headers */
|
||||||
#include "progmgr.h"
|
#include "progmgr.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "group.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
// #define WIN32_LEAN_AND_MEAN
|
// #define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#include <Shlobj.h>
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
GroupDlgProc -
|
NewGroupDlgProc -
|
||||||
Dialog procedure for creating or modifying
|
Dialog procedure for creating a group.
|
||||||
a group.
|
|
||||||
RETURNS -
|
RETURNS -
|
||||||
TRUE if message is handled, FALSE otherwise.
|
TRUE if message is handled, FALSE otherwise.
|
||||||
\* * * */
|
\* * * */
|
||||||
BOOL CALLBACK GroupDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
BOOL bOKEnabled = FALSE;
|
||||||
|
WCHAR szBuffer[] = { L"\0" };
|
||||||
|
HICON hIconDef = NULL;
|
||||||
|
HICON hIconDlg = NULL;
|
||||||
|
WCHAR szIconPath[MAX_PATH] = { L"\0" };
|
||||||
|
int iIconIndex = 0;
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
// TODO:
|
||||||
|
// Enable creation of common groups (enable the controls)
|
||||||
|
// if permissions are available.
|
||||||
|
|
||||||
// Place message cases here.
|
// Populate the icon with the default path and index.
|
||||||
|
GetModuleFileName(NULL, (LPWSTR)&szIconPath, MAX_PATH);
|
||||||
|
iIconIndex = IDI_PROGGRP - 1;
|
||||||
|
|
||||||
|
// Get the default hIcon so we can delete it later
|
||||||
|
hIconDef = (HICON)SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_GETICON, 0, 0);
|
||||||
|
|
||||||
|
// Set the icon in the dialog
|
||||||
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, iIconIndex);
|
||||||
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
|
|
||||||
|
// Set the maximum input length of the text boxes
|
||||||
|
SendDlgItemMessage(hWndDlg, IDD_NAME, EM_LIMITTEXT, MAX_TITLE_LENGTH, 0);
|
||||||
|
|
||||||
|
// Disable the OK button since we're starting with no text in the box.
|
||||||
|
EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch (GET_WM_COMMAND_ID(wParam, lParam))
|
||||||
|
{
|
||||||
|
|
||||||
|
case IDD_CHICON:
|
||||||
|
if (PickIconDlg(hWndDlg, (LPWSTR)&szIconPath, ARRAYSIZE(szIconPath), &iIconIndex) == TRUE)
|
||||||
|
{
|
||||||
|
// Since we've got the new icon...
|
||||||
|
hIconDlg = ExtractIcon(hAppInstance, (LPWSTR)&szIconPath, iIconIndex);
|
||||||
|
SendDlgItemMessage(hWndDlg, IDD_STAT_ICON, STM_SETICON, (WPARAM)hIconDlg, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDD_OK:
|
||||||
|
// Check that all the applicable fields are filled out
|
||||||
|
bOKEnabled = GetDlgItemText(hWndDlg, IDD_NAME, (LPWSTR)&szBuffer, ARRAYSIZE(szBuffer));
|
||||||
|
|
||||||
|
// Enable or disable the OK button based on the information
|
||||||
|
EnableWindow(GetDlgItem(hWndDlg, IDD_OK), bOKEnabled);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDD_CANCEL:
|
||||||
|
EndDialog(hWndDlg, FALSE);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Cleanup
|
||||||
|
if (hIconDef)
|
||||||
|
DestroyIcon(hIconDef);
|
||||||
|
if (hIconDlg)
|
||||||
|
DestroyIcon(hIconDlg);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * * *\
|
/* * * *\
|
||||||
ItemDlgProc -
|
NewItemDlgProc -
|
||||||
Dialog procedure for creating or modifying
|
Dialog procedure for creating or modifying
|
||||||
an item.
|
an item.
|
||||||
RETURNS -
|
RETURNS -
|
||||||
TRUE if message is handled, FALSE otherwise.
|
TRUE if message is handled, FALSE otherwise.
|
||||||
\* * * */
|
\* * * */
|
||||||
BOOL CALLBACK ItemDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
|
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
|
|
||||||
// Place message cases here.
|
// Place message cases here.
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_COMMAND:
|
||||||
|
switch (GET_WM_COMMAND_ID(wParam, lParam))
|
||||||
|
{
|
||||||
|
|
||||||
|
case IDD_CANCEL:
|
||||||
|
EndDialog(hWndDlg, FALSE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
@@ -12,5 +12,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/* Function Prototypes */
|
/* Function Prototypes */
|
||||||
BOOL CALLBACK ItemDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK NewGroupDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
BOOL CALLBACK GroupDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
BOOL CALLBACK NewItemDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
/* Headers */
|
/* Headers */
|
||||||
#include "progmgr.h"
|
#include "progmgr.h"
|
||||||
|
#include "dialog.h"
|
||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#include "registry.h"
|
#include "registry.h"
|
||||||
@@ -39,7 +40,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
{
|
{
|
||||||
if ((wParam >= IDM_MAIN) || (wParam <= IDM_TASKMGR))
|
if ((wParam >= IDM_MAIN) && (wParam <= IDM_TASKMGR))
|
||||||
{
|
{
|
||||||
if (wParam == IDM_TASKMGR)
|
if (wParam == IDM_TASKMGR)
|
||||||
{
|
{
|
||||||
@@ -97,6 +98,14 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||||||
ExitWindowsDialog(hWnd);
|
ExitWindowsDialog(hWnd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IDM_FILE_NEW_GROUP:
|
||||||
|
DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_GROUP), hWnd, (DLGPROC)NewGroupDlgProc);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IDM_FILE_NEW_ITEM:
|
||||||
|
DialogBox(hAppInstance, MAKEINTRESOURCE(DLG_ITEM), hWnd, (DLGPROC)NewItemDlgProc);
|
||||||
|
break;
|
||||||
|
|
||||||
case IDM_FILE_RUN:
|
case IDM_FILE_RUN:
|
||||||
RunFileDlg(hWnd, NULL, NULL, NULL, NULL, RFF_CALCDIRECTORY);
|
RunFileDlg(hWnd, NULL, NULL, NULL, NULL, RFF_CALCDIRECTORY);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user