#include <windows.h>
#include "stdafx.h"
#include <winsock.h>
#include "Resource.h"
#include <stdio.h>
#include <tchar.h>
#include <commctrl.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
/* Pro mysql */
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <mysql.h>
#pragma comment(lib,"libmysql.lib")
using namespace std;
int Windowsizex = 400;
int Windowsizey = 500;
#define CPPCONN_LIB_BUILD True
#define _AppName TEXT("KAE Setup")
MYSQL *mysql;
void log(char error[255]){
time_t t;
struct tm *pt;
t = time(NULL);
pt = localtime(&t);
FILE *log;
log = fopen("log.txt","a+");
fprintf(log," %i.%i.%i, %i:%i:%i ",pt->tm_mday, pt->tm_mon + 1, pt->tm_year + 1900, pt->tm_hour, pt->tm_min, pt->tm_sec,pt->tm_isdst ? "let" : "zim" );
fprintf(log,error);
fclose(log);
}
bool YesNo (HWND Okno){
TCHAR *msg=TEXT("Opravdu zavřít? ");
if ( MessageBox(Okno, msg, _AppName,
MB_YESNO | MB_ICONQUESTION) != IDYES )
return 0;
}
void Menu (HWND Okno){
}
INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch ( uMsg )
{
case WM_COMMAND:
switch ( LOWORD(wParam) )
{
case IDOK:
EndDialog(hwndDlg, IDOK);
break;
case IDCANCEL:
EndDialog(hwndDlg, IDCANCEL);
break;
}
break;
}
return FALSE;
}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
TCHAR szAppName[] = TEXT("WinApi KOD");
HWND hWnd;
MSG msg;
WNDCLASSEX wc;
log("Start \n");
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hIconSm = NULL;
wc.hCursor = (HCURSOR)LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
wc.lpszClassName = szAppName;
RegisterClassEx(&wc);
hWnd = CreateWindowEx(0,szAppName,
szAppName,
WS_OVERLAPPEDWINDOW,
200,
200,
Windowsizex,
Windowsizey,
NULL,
NULL,
hInstance,NULL);
ShowWindow(hWnd, iCmdShow);
UpdateWindow(hWnd);
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
if (YesNo(hWnd) ==0){
return 0;
}
else{
cout << "Zapis";
system("pause");
log("Konec \n");
PostQuitMessage(0);
}
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
Dobry den
Udelal Jsem si malinky zakladni programek v C++ WinApi viz vyse a funguje dle predstav..ale nejak jsem ve vizualku nepochopil vypsani si promenne do konzole Konkretne radky:
~~cout << "Zapis";
system("pause");
log("Konec \n");
PostQuitMessage(0);
Vse provede..podle me aj cout ale nikde ho nevidim vypsany..i proto jsem si udelal svuj log do txt, ale tohle nejde takhle delat vecne..Takze pro mnohe asi jednoduche ale me to nedochazi..Proc se mi pro vypsani cout neotevre nespusti konzole a cout my nevypise,i kdyz system pauze ceka na stisknuti klavesnice a konzole se normalne otevre?
Prechazim z pythonu a PHP a tam jsem s vypsanim promenych problemy nemel. Hlavne v Pythonu..Pygameu..jsem problemy nemel..ale tam je to trochu jinak.
Muze mi nekdo osvetlit poradit
Strycka googla jsem opravdu pouzil, ale bud jsem blbej a nedochazi mi to nebo delam chybu
Diky