본문 바로가기
컴퓨터과학[2-1]/knou_[2-1]Visual_C

wxWidgets

by boolean 2020. 7. 19.
728x90

wxWidgets

참고동영상

wxWidgets 3.0 Documentation 


현재학습

1. Project properties

수동설정


Cannot open include file.... : (#include <wx/wx.h>)

Project_name(right_click) > properties > C/C++ > Genneral > Addition include Directories > $(WXWIDGET)\include,  |  $(WXWIDGET)\include\msvc) 경로지정


Cannot open file.... : (error LNK1104)

Project_name(right_click) > properties > LINK > Genneral > Addition Library Directories > $WXWIDET)\lib\vc_lib 경로지정


Project 생성후 Header Files와 Source Files 내부의 모든 파일을 삭제한후 필요한 클래스를 추가해서 사용한다.

속성 관리자를 이용한 설정

임의의 project를 생성후에 View > 속성관리자  창을 연후에 프로젝트명 우클릭 >새프로젝트 속성 시트 추가를 선택한 후에 아래를 진행한다
저정장소는 되도록이면 솔루션 폴더 안에 위치하게 한다

Stastic_Wx
Project_name(right_click) > properties > C/C++ > Genneral > Addition include Directories > $(WXWIDGET)\include,  |  $(WXWIDGET)\include\msvc) 경로지정

Project_name(right_click) > properties > LINK > Genneral > Addition Library Directories > $WXWIDET)\lib\vc_lib 경로지정

dll_Wx
Project_name(right_click) > properties > C/C++ > Genneral > Addition include Directories > $(WXWIDGET)\include,  |  $(WXWIDGET)\include\msvc) 경로지정

Project_name(right_click) > properties > LINK > Genneral > Addition Library Directories > $WXWIDET)\lib\vc_dll 경로지정

참고 동영상 -  wxWidgets - 환경 설정과 Hello World 샘플

2. Hello World

Create a Project

Add a Class MyApp

MyApp.h


#pragma once

#include <wx wx.h>
class MyApp: public wxApp
{
public:
	MyApp();
	~MyApp();

	virtual bool OnInit();
};

DECLARE_APP(MyApp);

MyApp.cpp


#include "MyApp.h"
#include "MyFrame.h"

IMPLEMENT_APP(MyApp);

MyApp::MyApp(void)
{

}

MyApp::~MyApp(void)
{

}

bool
MyApp::OnInit() {
	wxFrame* frame = new MyFrame("Hello World");
	frame->Show(true);

	return true;

}

Add a Class MyFrame

MyFrame.h


#pragma once

#include <wx wx.h>
class MyFrame : public wxFrame
{
public:
	MyFrame(const wxString& title);
	~MyFrame(void);
};

MyFrame.cpp

#include "MyFrame.h"

MyFrame::MyFrame(const wxString& title)
	:wxFrame(NULL, wxID_ANY, title)
{
	new wxPanel(this);

}

MyFrame::~MyFrame(void)
{

}


3. MenuBar

Create a Project

Add a Class MyApp

MyApp.h


#pragma once

#include <wx\wx.h>

class MyApp:public wxApp
{

	virtual bool OnInit();
};

DECLARE_APP(MyApp);

MyApp.cpp


#include "MyApp.h"
#include "MyFrame.h"

IMPLEMENT_APP(MyApp);

bool
MyApp::OnInit() {
	wxFrame* m = new MyFrame("Hello Button");
	m->Show(true);

	return true;
}

Add a Class MyFrame

MyFrame.h


#pragma once

#include <wx/wx.h>

class MyFrame:public wxFrame
{
	enum {
		ID_QUIT = 1,
		ID_HELP,
		ID_PROPERTIES,
	};
public:
	MyFrame(const wxString& title);
	~MyFrame(void);

private:
	void OnQuit(wxCommandEvent& event);
	void OnHelp(wxCommandEvent& event);

	DECLARE_EVENT_TABLE()
};

MyFrame.cpp

#include "MyFrame.h"
#include 

BEGIN_EVENT_TABLE(MyFrame, wxFrame)
	EVT_MENU(ID_QUIT, MyFrame::OnQuit)
	EVT_BUTTON(ID_QUIT, MyFrame::OnQuit)
	EVT_MENU(ID_HELP, MyFrame::OnHelp)
	EVT_BUTTON(ID_HELP, MyFrame::OnHelp)

END_EVENT_TABLE()


MyFrame::MyFrame(const wxString& title)
	:wxFrame(NULL, wxID_ANY, title)
{

	wxMenu* menuFile = new wxMenu;
	menuFile->Append(ID_QUIT, "&Quit\tCTRL+Q");
	menuFile->Append(ID_HELP, "&Help\tCTRL+H");
	menuFile->Append(ID_PROPERTIES, "&Properties");

	wxMenuBar* menuBarFile = new wxMenuBar;
	menuBarFile->Append(menuFile, "&File");
	this->SetMenuBar(menuBarFile);

	wxPanel* panel = new wxPanel(this);
	wxButton* btn = new wxButton(panel, ID_QUIT, "&Quit", wxPoint(10, 10));
	wxButton* btn2 = new wxButton(panel, ID_HELP, "&Help", wxPoint(90, 10));

}

MyFrame::~MyFrame(void)
{

}

void
MyFrame::OnQuit(wxCommandEvent& event) {
	this->Close();
}

void
MyFrame::OnHelp(wxCommandEvent& event) {
	this->Close();
}

3. Text Control_1

MyApp.cpp

MyApp.h

MyFrame.cpp

MyFrame.h


4. Text Control_2






댓글