... This is my complete start up code.
... Included is a picture of my window after I run this code.
... What am I doing wrong? I don't know the words to ask for the help I need sometimes.
... My static text is not transparent. Why?
... Be as critical and constructive as you want. I need a lot of help.
...DrawingInterface.h
// menu identifiers
#define IDM_FILE_NEW 1001
#define IDM_FILE_OPEN 1002
#define IDM_FILE_QUIT 1003
#define IDM_FILE_SAVEAS 1004
#define IDM_VIEW_TOOLBAR 2001 // toolbar area
#define IDM_VIEW_TV_TITLE 2002 // treeview title area
#define IDM_VIEW_TREEVIEW 2003 // treeview area
#define IDM_VIEW_TV_BUTTONS 2004 // treeview buttons area
#define IDM_VIEW_PB_TITLE 2005 // picturebox title area
#define IDM_VIEW_PICTUREBOX 2006 // picturebox area
#define IDM_VIEW_STATUSBAR 2007 // statusbar area
#define IDS_STATIC_TREE 3001 // Treeview Label
struct VisibleControls {
bool toolbarVisible;
bool treeviewTitleVisible;
bool treeviewVisible;
bool treeviewButtonsVisible;
bool pictureboxTitleVisible;
bool pictureboxVisible;
bool statusbarVisible;
}visCon;
... DrawingInterface.c
/*
* Author Steve Griffin
* Begin Sep. 28, 2013
* Create a basic user interface for my drawing applications.
* Will include menubar, toolbar, 2 labels, treeview, picturebox, button area and statusbar.
*
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>
#include <stdbool.h>
#include <stdio.h>
#include "DrawingInterface.h"
#pragma comment(linker, "-subsystem:console")
#pragma comment(linker, "-entry:wWinMainCRTStartup")
// prototypes
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
void AddMenus(HWND);
void AddToolbar(HWND);
void hideShowTool(bool);
void AddTreeViewTitle(HWND);
// module level variables
HWND hThisInstance;
HMENU hMenu;
HMENU hMenuView;
static HWND hTool = NULL;
static HWND hLabel = NULL;
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow){
printf("The console will be my value checker log.\n");
//fclose(stdout);
//*stdout = *fopen("c:\\debug.log", "w");
//printf ("This is the degug log for DrawingInterface.exe");
HBRUSH hb = CreateSolidBrush(RGB(0,128,128));
MSG msg;
WNDCLASSW wc = { 0 };
wc.lpszClassName = L"DrawingInterface";
wc.hInstance = hInstance;
wc.hbrBackground = hb;
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
RegisterClassW(&wc);
CreateWindowW(wc.lpszClassName, L"Drawing Interface", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 30, 400, 400, 0, 0, hInstance, 0);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
// obligatory call - does nothing but cause win32.dll to recognize us
INITCOMMONCONTROLSEX iccex;
iccex.dwICC = ICC_WIN95_CLASSES;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&iccex);
UINT state;
static HBRUSH hbBack = 0;
switch (msg)
{
case WM_CREATE:
AddMenus(hwnd);
AddToolbar(hwnd);
AddTreeViewTitle(hwnd);
break;
case WM_SIZING:
//FitAreas(hwnd);
break;
case WM_EXITSIZEMOVE:
//RepositionPanels(hwnd);
break;
case WM_MOVE:
break;
case WM_INITDIALOG:
hbBack = CreateSolidBrush(RGB(255, 255, 0));
case WM_CLOSE:
DeleteObject(hbBack);
case WM_CTLCOLORSTATIC:
//hdc = (HDC)wParam;
SetTextColor((HDC)wParam, RGB(255, 0, 0)); // red
SetBkColor((HDC)wParam, RGB(255, 255, 0)); // yellow
return (LRESULT)hbBack;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDM_FILE_NEW:
break;
case IDM_FILE_OPEN:
Beep(50, 100);
break;
case IDM_FILE_QUIT:
SendMessage(hwnd, WM_CLOSE, 0, 0);
break;
case IDM_VIEW_TOOLBAR:
state = GetMenuState(hMenuView, IDM_VIEW_TOOLBAR, MF_BYCOMMAND);
if (state == SW_SHOWNA) {
hideShowTool(0);
CheckMenuItem(hMenuView, IDM_VIEW_TOOLBAR, MF_UNCHECKED);
} else {
hideShowTool(1);
CheckMenuItem(hMenuView, IDM_VIEW_TOOLBAR, MF_CHECKED);
}
break;
case IDM_VIEW_TV_TITLE:
break;
case IDM_VIEW_TREEVIEW:
break;
case IDM_VIEW_TV_BUTTONS:
break;
case IDM_VIEW_PB_TITLE:
break;
case IDM_VIEW_PICTUREBOX:
break;
case IDM_VIEW_STATUSBAR:
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProcW(hwnd, msg, wParam, lParam);
}
void AddMenus(HWND hwnd){
HMENU hMenubar;
hMenubar = CreateMenu();
hMenu = CreateMenu();
hMenuView = CreateMenu();
// file menu sub items
AppendMenuW(hMenu, MF_STRING, IDM_FILE_NEW, L"&New");
AppendMenuW(hMenu, MF_STRING, IDM_FILE_OPEN, L"&Open");
AppendMenuW(hMenu, MF_SEPARATOR, 0, NULL);
AppendMenuW(hMenu, MF_STRING, IDM_FILE_QUIT, L"&Quit");
// view menu sub items
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_TOOLBAR, L"Toolbar");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_TV_TITLE, L"TV Title");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_TREEVIEW, L"Treeview");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_TV_BUTTONS, L"TV Buttons");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_PB_TITLE, L"PB Title");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_PICTUREBOX, L"Picturebox");
AppendMenuW(hMenuView, MF_STRING, IDM_VIEW_STATUSBAR, L"Statusbar");
// turn menuitems into check menus
CheckMenuItem(hMenuView, IDM_VIEW_TOOLBAR, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_TV_TITLE, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_TREEVIEW, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_TV_BUTTONS, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_PB_TITLE, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_PICTUREBOX, MF_CHECKED);
CheckMenuItem(hMenuView, IDM_VIEW_STATUSBAR, MF_CHECKED);
// file menu bar item
AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenu, L"&File");
AppendMenuW(hMenubar, MF_POPUP, (UINT_PTR)hMenuView, L"&View");
SetMenu(hwnd, hMenubar);
}
void AddToolbar(HWND hwnd)
{
// obligatory call - does nothing but cause win32.dll to recognize us
//INITCOMMONCONTROLSEX iccex;
//iccex.dwICC = ICC_WIN95_CLASSES;
//iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
//InitCommonControlsEx(&iccex);
hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hwnd, (HMENU)1, GetModuleHandle(NULL), NULL);
// Send the TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
TBBUTTON tbb[3];
TBADDBITMAP tbab;
tbab.hInst = HINST_COMMCTRL;
tbab.nID = IDB_STD_SMALL_COLOR;
SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM) & tbab);
ZeroMemory(tbb, sizeof(tbb));
tbb[0].iBitmap = STD_FILENEW;
tbb[0].fsState = TBSTATE_ENABLED;
tbb[0].fsStyle = TBSTYLE_BUTTON;
tbb[0].idCommand = IDM_FILE_NEW;
tbb[1].iBitmap = STD_FILEOPEN;
tbb[1].fsState = TBSTATE_ENABLED;
tbb[1].fsStyle = TBSTYLE_BUTTON;
tbb[1].idCommand = IDM_FILE_OPEN;
tbb[2].iBitmap = STD_FILESAVE;
tbb[2].fsState = TBSTATE_ENABLED;
tbb[2].fsStyle = TBSTYLE_BUTTON;
tbb[2].idCommand = IDM_FILE_SAVEAS;
SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb) / sizeof(TBBUTTON), (LPARAM) & tbb);
}
void hideShowTool(bool visibility){
if (visibility == 0) {
ShowWindow(hTool,SW_HIDE);
MessageBoxA(hThisInstance,"hidden","Hide Toolbar",MB_OK);
} else {
ShowWindow(hTool,SW_SHOW);
MessageBoxA(hThisInstance,"hidden","Hide Toolbar",MB_OK);
}
}
void AddTreeViewTitle(HWND hwnd)
{
static char *TreeViewTitle = " TREE VIEW TITLE";
hLabel = CreateWindow("STATIC", TreeViewTitle, WS_CHILD | WS_VISIBLE | SS_LEFT,
5, 40, 125, 18, hwnd, (HMENU) IDS_STATIC_TREE, NULL, NULL);
static HFONT hFont;
static int nSize = 18;
if (hFont) DeleteObject(hFont);
hFont = CreateFont(nSize, 0, 0, 0, FW_BOLD, 0, 0, 0, ANSI_CHARSET,
0, 0, 0, 0, TEXT("Comic Sans MS"));
SendDlgItemMessage(hwnd, IDS_STATIC_TREE, WM_SETFONT, (WPARAM)hFont, TRUE);
}