Ok jeg har nu et program der ser sådan ud:
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <shlobj.h>
#include <string>
HINSTANCE InstanceHandle;
HWND MainWindow;
STARTUPINFO si =
{
sizeof(STARTUPINFO),
NULL,
NULL,
"Title",
0, 0, 0, 0,
0, 0,
0,
0,
0,
0,
0,
0,
0,
0
};
PROCESS_INFORMATION pi;
enum numbers {
button = 1000,
};
void DoPaint(HDC dc)
{
HFONT Font = CreateFont(32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, "Comic Sans MS");
SetTextColor(dc, RGB(255, 0, 0));
SetBkMode(dc, TRANSPARENT);
HGDIOBJ OldFont = SelectObject(dc, Font);
TextOut(dc, 170, 15, "Installer Bots", 14);
SelectObject(dc, OldFont);
DeleteObject(Font);
}
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_CREATE:
CreateWindow("BUTTON",
"Installer",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
190, 180, 110, 30,
hwnd,
(HMENU) (button),
InstanceHandle,
0);
break;
case WM_COMMAND:
if(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == button) {
std::string GetFolder()
{
BROWSEINFO BrowseInfo;
char temp[1024];
BrowseInfo.hwndOwner = 0;
BrowseInfo.pidlRoot = 0;
BrowseInfo.pszDisplayName = temp;
BrowseInfo.lpszTitle = "Select install path";
BrowseInfo.ulFlags = 0;
BrowseInfo.lpfn = 0;
BrowseInfo.lParam = 0;
BrowseInfo.iImage = 0;
ITEMIDLIST *ItemList = SHBrowseForFolder(&BrowseInfo);
if(ItemList)
{
SHGetPathFromIDList(ItemList, temp);
return std::string(temp);
}
return std::string("");
}
std::string Path = GetFolder();
MessageBox(0, Path.c_str(), "You selected:", MB_OK);
}
break;
case WM_PAINT:
HDC dc;
PAINTSTRUCT PaintStruct;
dc = BeginPaint(hwnd, &PaintStruct);
DoPaint(dc);
EndPaint(hwnd, &PaintStruct);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
HWND CreateMainWindow()
{
WNDCLASS wc;
memset(&wc, 0, sizeof(WNDCLASS));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ;
wc.lpfnWndProc = (WNDPROC )MainWndProc;
wc.hInstance = InstanceHandle;
wc.hbrBackground = (HBRUSH )(COLOR_BTNFACE + 1);
wc.lpszClassName = "SimpleWinWndClass";
wc.lpszMenuName = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClass(&wc))
return 0;
return CreateWindow("SimpleWinWndClass",
"Installer Bots",
WS_MINIMIZEBOX | WS_VISIBLE |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
WS_CAPTION | WS_BORDER | WS_SYSMENU | WS_THICKFRAME,
CW_USEDEFAULT, 0, 500, 300,
0,
0,
InstanceHandle,
0);
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
INT nCmdShow)
{
InstanceHandle = hInstance;
if((MainWindow = CreateMainWindow()) == (HWND )0)
{
MessageBox(0, "Failed to create MainWindow!", "Warning", MB_OK);
return 0;
}
ShowWindow(MainWindow, SW_SHOW);
MSG Msg;
while(GetMessage(&Msg, 0, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
Men jeg får disse fejl:
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
botinstall.cpp:
Error E2108 botinstall.cpp 71: Improper use of typedef 'std::string' in function
__stdcall MainWndProc(HWND__ *,unsigned int,unsigned int,long)
Error E2379 botinstall.cpp 71: Statement missing ; in function __stdcall MainWnd
Proc(HWND__ *,unsigned int,unsigned int,long)
Error E2451 botinstall.cpp 93: Undefined symbol 'Path' in function __stdcall Mai
nWndProc(HWND__ *,unsigned int,unsigned int,long)
*** 3 errors in Compile ***