C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 23rd, 2003, 11:24 AM
Milky_Destrecto Milky_Destrecto is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 Milky_Destrecto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation Help!!

can someone give me the whole source to my program and give it back to me with save and open being able to open .map files and edit .map files and on the bottom of the program a scrollbar with the file tiles.bmp i know its alot but its important once i get that i know how to do the rest i dont know the source and i cant figure it out and im a computer admin for god sake! lol

#include <windows.h>
#include <commctrl.h>
#include "resource.h"

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
void HandleMenu (HWND hwnd, UINT Command);
HWND CreateStatusbar (HWND hwnd);
HWND CreateToolbar (HWND hwnd);

/* Make the class name into a global variable */
char szClassName[ ] = "WindowsApp";
HWND hWndMain; /* This is the handle for our window */
HWND hWndStatusbar, hWndToolbar;

int WINAPI
WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int cmdShow)
{
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
HMENU hMenu; /* Handle for the menu */
HACCEL hAccKeys;

/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (hThisInstance, MAKEINTRESOURCE (IDI_GCM));
wincl.hIconSm = LoadIcon (hThisInstance, MAKEINTRESOURCE (IDI_GCM));
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default color as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;

/* The class is registered, let's create the program*/
hWndMain = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"GcmWin", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);

/* Load the menu */
hMenu = LoadMenu (hThisInstance, "MAINMENU");
SetMenu (hWndMain, hMenu);

/* Load accelerator keys (ex. Ctrl-N) */
hAccKeys = LoadAccelerators (hThisInstance, "IDR_ACCKEYS");

/* Make the window visible on the screen */
ShowWindow (hWndMain, cmdShow);

/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
if (!TranslateAccelerator(hWndMain, hAccKeys, &messages))
{
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
}

/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}


/* This function is called by the Windows function DispatchMessage() */

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int iStatus[4]; // Number of fields in statusbar
HWND hWndTT;
LPTOOLTIPTEXT lpToolTipText;
TOOLINFO lpToolInfo;
char text[80];

switch (message) /* handle the messages */
{
case WM_CREATE:
hWndStatusbar = CreateStatusbar (hwnd);
hWndToolbar = CreateToolbar (hwnd);
break;

case WM_COMMAND:
HandleMenu (hwnd, LOWORD (wParam));
break;

case WM_SIZE:
RECT rcFrame ,rc, rcClient;
// get size of frame window
GetClientRect(hwnd, &rcFrame);

GetWindowRect(hWndToolbar, &rc);
ScreenToClient(hwnd, (LPPOINT)&rc + 1);
rcClient.top = rc.bottom;

GetWindowRect(hWndStatusbar, &rc);
ScreenToClient(hwnd, (LPPOINT)&rc);

rcClient.bottom = rc.top - rcClient.top;

SendMessage (hWndStatusbar, WM_SIZE, wParam, lParam);

iStatus[3] = -1;
iStatus[2] = LOWORD (lParam) - 70;
iStatus[1] = LOWORD (lParam) - 140;
iStatus[0] = LOWORD (lParam) - 210;

SendMessage (hWndStatusbar, SB_SETPARTS, 4, (LPARAM) iStatus);
SendMessage (hWndStatusbar, SB_SETTEXT, 0, (LPARAM) "Field 0");
SendMessage (hWndStatusbar, SB_SETTEXT, 1, (LPARAM) "Field 1");
SendMessage (hWndStatusbar, SB_SETTEXT, 2, (LPARAM) "Field 2");
SendMessage (hWndStatusbar, SB_SETTEXT, 3, (LPARAM) "Field 3");

SendMessage (hWndToolbar, TB_AUTOSIZE, 0L, 0L);
InvalidateRgn (hWndMain, NULL, TRUE);
break;

case WM_NOTIFY:
// Show tooltips
if ((((LPNMHDR) lParam)->code) == TTN_NEEDTEXT)
{
lpToolTipText = (LPTOOLTIPTEXT) lParam;
// load from resources
LoadString ((HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE),
lpToolTipText->hdr.idFrom, // what menu command?
text, // the text
sizeof (text));
// Set the tooltip text
lpToolTipText->lpszText = text;
}
break;

case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}

return 0;
}

void HandleMenu (HWND hwnd, UINT Command)
{

switch (Command)
{
case IDM_NEW:
MessageBox (NULL, "New Map", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_SAVEBMP:
MessageBox (NULL, "Save Bitmap", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_SAVEBMPAS:
MessageBox (NULL, "Save Bitmap AS", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_OPTIONS:
MessageBox (NULL, "Options", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_DXPOS:
MessageBox (NULL, "DxPos", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_about:
MessageBox (NULL, "About", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_HELP:
MessageBox (NULL, "Help", "Menu", MB_OK | MB_ICONINFORMATION);
break;

case IDM_EXIT:
PostQuitMessage (0);
break;
}
return;
}

HWND CreateStatusbar (HWND hwnd)
{
HWND hWndFields;

hWndFields = CreateStatusWindow (WS_CHILD | WS_VISIBLE |
CCS_ADJUSTABLE | SBARS_SIZEGRIP, NULL, hwnd, IDR_STATUS);
return hWndFields;
}

HWND CreateToolbar (HWND hwnd)
{
const int NUMBUTTS = 8; // Number of buttons

TBBUTTON tbButtns[NUMBUTTS];
HBITMAP hbPict;

HINSTANCE hInst = (HINSTANCE) GetWindowLong (hwnd, GWL_HINSTANCE);
int i;

hbPict = LoadBitmap (hInst, MAKEINTRESOURCE (IDB_TOOL));

for (i = 0; i < NUMBUTTS; i++)
{
tbButtns[i].idCommand = 0;
tbButtns[i].fsState = TBSTATE_ENABLED;
// if ((i >= 1) && (i <= 4)) // If you want to group together some btns
// tbButtns[i].fsStyle = TBSTYLE_BUTTON | TBSTYLE_CHECKGROUP;
// else
tbButtns[i].fsStyle = TBSTYLE_BUTTON;
tbButtns[i].dwData = 0;
tbButtns[i].iString = 0;
}

tbButtns[0].iBitmap = 0; // Number in bitmap
tbButtns[0].idCommand = IDM_NEW; // Menu command
tbButtns[1].iBitmap = 1;
tbButtns[1].idCommand = IDM_SAVEBMP;

tbButtns[2].iBitmap = -1; // Separator
tbButtns[2].fsStyle = TBSTYLE_SEP;

tbButtns[3].iBitmap = 3;
tbButtns[3].idCommand = IDM_EXIT;
tbButtns[4].iBitmap = 4;
tbButtns[4].idCommand = IDM_OPTIONS;
tbButtns[5].iBitmap = 5;
tbButtns[5].idCommand = IDM_DXPOS;

tbButtns[6].iBitmap = -1; // Separator
tbButtns[6].fsStyle = TBSTYLE_SEP;

tbButtns[7].iBitmap = 6;
tbButtns[7].idCommand = IDM_HELP;


// buttons and icons 16x16 pixels
return CreateToolbarEx (hwnd, WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS, IDR_TOOLB,
NUMBUTTS, NULL, (UINT) hbPict, tbButtns, NUMBUTTS, 16, 16,
16, 16, sizeof (TBBUTTON));
}

Reply With Quote
  #2  
Old June 23rd, 2003, 11:27 AM
Milky_Destrecto Milky_Destrecto is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 5 Milky_Destrecto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ANOTHER FILE

#define IDB_TOOL 60
#define IDI_GCM 120

#define IDR_TOOLB 800
#define IDR_STATUS 900

#define IDM_NEW 10001
#define IDM_SAVEBMP 10002
#define IDM_SAVEBMPAS 10003
#define IDM_EXIT 10005
#define IDM_OPTIONS 10006
#define IDM_DXPOS 10007
#define IDM_ABOUT 10008
#define IDM_HELP 10009
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RESOURCE.H i think

#include <windows.h>
#include "resource.h"

IDB_TOOL BITMAP "toolbar.bmp
IDB_TOOL BITMAP "tiles.bmp
IDI_GCM ICON "gcmw.ico"

MAINMENU MENU
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&New Map", IDM_NEW
MENUITEM SEPARATOR
MENUITEM "&Save", IDM_SAVEBMP
MENUITEM "Save Undeditable", IDM_SAVEBMPAS
MENUITEM SEPARATOR
MENUITEM "&Exit", IDM_EXIT
END
MENUITEM "&Options", IDM_OPTIONS
MENUITEM "&Aoffline" , IDM_DXPOS
POPUP "&Help"
BEGIN
MENUITEM "&Help", IDM_HELP
MENUITEM SEPARATOR
MENUITEM "Credits", IDM_ABOUT
END
END

STRINGTABLE
BEGIN
IDM_NEW, "Create a new map"
IDM_SAVEBMP, "Save the map"
IDM_EXIT, "Exit Program"
IDM_OPTIONS, "Arc Offline Test"
IDM_DXPOS, "Credits"
IDM_HELP, "Helpfile!"
END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Help!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT