Hi.
I've been working on a graphical GUI editor for the past week or so. I =
have finally gotten to the stage where I can add buttons and
edit boxes without crashing Windows. Now the program outputs some source =
code for a C program. If anyone has the time and
patience to read the generated source code I'd appreciate some =
constructive feedback. I've never done GUI programming without
the use of a graphical resource editor, and I often find the =
documentation a bit vague at times. Any suggestions for better code
would be much appreciated. The purpose of Gogga is to create an editor =
to output C or C++ source code for a GUI application that
does not need resource files. There are plenty of resource editors, even =
a few graphical ones, but for the purpose of generation a
small dialog-based application I have yet to find a suitable tool.
As soon as I have the basic code sorted and cleaned out, I'll upload it =
to the open source section of my webpage. Please find
included at the bottom of this message the output generated from the =
editor Gogga. Comments are lacking, variable names could
be more descriptive and I will have it cut lines longer that 70 =
characters of and continue on the next line in the near future. If =
things
go well, I'll have some sort of a release ready for next week.
Oh, if there is a free program that does what I want, please tell me =
about it so I can stop reinventing the wheel!
Thank you
Ewald Horn
Proprietor/Eienaar : Horn Labs
Cell/Sel : 083 519 1615
Website : http://www.hornlabs.co.za
Email/E-pos : in...@ho...
[code]
/*
Output : WYSIWYG GUI EDITOR 0.02
File : main.c
*/
#include <windows.h>
LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
char szClassName[] =3D "GoggaClass";
// WinMain()
int WINAPI WinMain(HINSTANCE CurInst, HINSTANCE PreInst, LPSTR Args, int =
status)
{
HWND hwnd; =20
MSG msgs; =20
WNDCLASSEX wincl; =20
HANDLE button1,edit1;
wincl.hInstance =3D CurInst;
wincl.lpszClassName =3D szClassName;
wincl.lpfnWndProc =3D WindowProcedure; =20
wincl.style =3D CS_DBLCLKS; =20
wincl.cbSize =3D sizeof(WNDCLASSEX);
wincl.hIcon =3D LoadIcon(NULL, IDI_APPLICATION);
wincl.hIconSm =3D LoadIcon(NULL, IDI_APPLICATION);
wincl.hCursor =3D LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName =3D NULL; =20
wincl.cbClsExtra =3D 0; =20
wincl.cbWndExtra =3D 0; =20
wincl.hbrBackground =3D (HBRUSH)COLOR_BACKGROUND;
if (!RegisterClassEx(&wincl))
return 0;
hwnd =3D CreateWindowEx(0, szClassName, "User Title", WS_CAPTION | =
WS_SYSMENU, CW_USEDEFAULT, =20
CW_USEDEFAULT, 400, 400, HWND_DESKTOP, NULL, CurInst, NULL);
button1=3DCreateWindowEx(WS_EX_STATICEDGE,"button","OK",WS_CHILD | =
WS_VISIBLE | BS_MULTILINE | BS_PUSHBUTTON | =
WS_TABSTOP,20,20,32,32,hwnd,NULL,CurInst,NULL);
button1=3DCreateWindowEx(WS_EX_STATICEDGE,"edit","Change =
Me!",WS_CHILD | WS_VISIBLE | =
ES_WANTRETURN,20,60,100,20,hwnd,NULL,CurInst,NULL);
RedrawWindow(hwnd,0,0,0);
ShowWindow(hwnd, SW_SHOW);
while (GetMessage(&msgs, NULL, 0, 0))
{
TranslateMessage(&msgs);
DispatchMessage(&msgs);
}
return msgs.wParam;
}
// WindowProcedure
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT msg, WPARAM wParam, =
LPARAM lParam)
{
switch(msg) =20
{
case WM_DESTROY:
PostQuitMessage (0); =20
break;
default: =20
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
[end code] |