#include <windows.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include "resource.h" #include "aw.h" #define version "0.0.0.1" #define connect0 "Connection en cours...\n" #define connect1 "Connecté!" #define proprio 1 HINSTANCE hInst = NULL; HWND hwnd = NULL; WNDCLASS fenetre; HINSTANCE hinst; HWND hedname; HWND hdlg; HWND hWnd; char nom[50]; char pass[50]; char univers[50]; char monde[50]; /* Declarations*/ char sortie[11]; BOOL OnCommand(UINT id, HWND hwnd); HANDLE hIcon; // déclaration du handle de l'icône LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam); LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK WindowProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam) {return (DefWindowProc(hwnd, msg, wparam, lparam));} LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: SendMessage(GetDlgItem(hWnd, IDC_MESSAGE), LB_ADDSTRING, NULL, (LPARAM)(LPCSTR) connect0); SetDlgItemText(hwnd,IDC_VERSION,version); GetPrivateProfileString("BOT","nom",NULL,nom,sizeof(nom),".\\config.ini"); SetDlgItemText(hwnd,IDC_NAME,nom); GetPrivateProfileString("BOT","pass",NULL,pass,sizeof(pass),".\\config.ini"); GetPrivateProfileString("BOT","univers",NULL,univers,sizeof(univers),".\\config.ini"); SetDlgItemText(hwnd,IDC_UNI,univers); GetPrivateProfileString("BOT","monde",NULL,monde,sizeof(monde),".\\config.ini"); SetDlgItemText(hwnd,IDC_MONDE,monde); /* Permet de cacher ID_CHECKINIENRE*/ EnableWindow(GetDlgItem(hwnd,ID_CHECKINIENRE),FALSE); break; case WM_COMMAND: { OnCommand(LOWORD(wParam), hwnd); switch(LOWORD(wParam)) { case WM_DESTROY: { EndDialog(hwnd, FALSE); break; } } break; } default: return FALSE; } return TRUE; } int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { fenetre.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; fenetre.lpfnWndProc = WindowProc; fenetre.cbClsExtra = 0; fenetre.cbWndExtra = 0; fenetre.hInstance = hInstance; fenetre.hIcon = LoadIcon(NULL, IDI_EXCLAMATION); fenetre.hCursor = LoadCursor(NULL, IDC_ARROW); fenetre.hbrBackground = (struct HBRUSH__ *)GetStockObject(WHITE_BRUSH); fenetre.lpszMenuName = NULL; fenetre.lpszClassName = "EX-INI"; if (!RegisterClass(&fenetre)) return(0); hInst = hInstance; // Active la boîte de dialogue DialogBox(hInst, MAKEINTRESOURCE(IDD_MENU), NULL, ( DLGPROC ) DlgProc); return (0); } BOOL OnCommand(UINT id, HWND hwnd) // fonction gérant le menu { switch(id) { case ID_QUIT: EndDialog(hwnd,FALSE); return 0; case ID_PARTIR: EndDialog(hwnd,0); return TRUE; case ID_CONNECT: int rc; char msg[256]; if (rc = aw_init (AW_BUILD)) { MessageBox(hwnd,"Impossible d'initialiser l'API","Erreur",MB_OK); exit (1); } if (rc = aw_create (univers, 0, 0)) { MessageBox(hwnd,"Impossible de se connecter à l'univers!","Erreur!",MB_OK);} aw_string_set (AW_LOGIN_NAME, nom); aw_int_set (AW_LOGIN_OWNER, proprio); aw_string_set (AW_LOGIN_PRIVILEGE_PASSWORD, pass); aw_string_set (AW_LOGIN_APPLICATION, "Eole"); if (rc = aw_login ()) MessageBox(hwnd,"Impossible de s'identifier!","Erreur",MB_OK); if (rc = aw_enter (monde)) { MessageBox(hwnd,"Impossible d'entrer dans le monde spécifié","Erreur",MB_OK);} aw_int_set (AW_MY_X, 0); aw_int_set (AW_MY_Z, 0); aw_int_set (AW_MY_YAW, 0); if (rc = aw_state_change ()) { MessageBox(hwnd,"Impossible de se localiser dans le monde spécifié","Erreur",MB_OK);} printf ("%s\n",aw_string(AW_WORLD_WELCOME_MESSAGE)); while (!aw_wait(-1)) aw_destroy (); aw_term (); return TRUE; case TEST: return 0; } }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question