Skip to content

Commit

Permalink
重构部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
WallBreaker2 committed Aug 25, 2020
1 parent c3a7e35 commit 2c22cab
Show file tree
Hide file tree
Showing 16 changed files with 627 additions and 346 deletions.
34 changes: 21 additions & 13 deletions op/Bkbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
#include "globalVar.h"
#include "helpfunc.h"
#include "Bkbase.h"

bkbase::bkbase() :_hwnd(0), _is_bind(0), _pbkdisplay(nullptr)
#include "winkeypad.h"
bkbase::bkbase() :_hwnd(0), _is_bind(0), _pbkdisplay(nullptr),_keypad(new winkeypad)
{
_display_method = std::make_pair<wstring, wstring>(L"screen", L"");
}

bkbase::~bkbase()
{
_hwnd = NULL;
/*_hwnd = NULL;
_is_bind = 0;
_mode = 0;
_bkmouse.UnBind();
if (_pbkdisplay) {
_pbkdisplay->UnBind();
delete _pbkdisplay;
_pbkdisplay = nullptr;
}
}*/
UnBindWindow();
}

long bkbase::BindWindow(long hwnd, const wstring& sdisplay, const wstring& smouse, const wstring& skeypad, long mode) {
Expand Down Expand Up @@ -84,10 +85,7 @@ long bkbase::BindWindow(long hwnd, const wstring& sdisplay, const wstring& smous
set_display_method(L"screen");
_mode = mode;
_display = display;
if (!_bkmouse.Bind(_hwnd, mouse))
return 0;
if (!_keypad.Bind(_hwnd, keypad))
return 0;


if (display == RDT_NORMAL || GET_RENDER_TYPE(display) == RENDER_TYPE::GDI) {
_pbkdisplay = new bkgdi();
Expand All @@ -107,6 +105,13 @@ long bkbase::BindWindow(long hwnd, const wstring& sdisplay, const wstring& smous
return 0;
}
}

if (!_bkmouse.Bind(_hwnd, mouse))
return 0;
/* if (mouse == INPUT_TYPE::IN_NORMAL || mouse == INPUT_TYPE::IN_WINDOWS)*/
_keypad = new winkeypad;
if (!_keypad->Bind(_hwnd, keypad))
return 0;
//等待线程创建好
Sleep(200);

Expand All @@ -118,17 +123,20 @@ long bkbase::BindWindow(long hwnd, const wstring& sdisplay, const wstring& smous
}

long bkbase::UnBindWindow() {
//to do
//clear ....
_hwnd = NULL;
_is_bind = 0;
_mode = 0;

_bkmouse.UnBind();
if (_pbkdisplay) {
_pbkdisplay->UnBind();
delete _pbkdisplay;
_pbkdisplay = nullptr;
SAFE_DELETE(_pbkdisplay);
}


SAFE_DELETE(_keypad);

return 1;
}

Expand Down Expand Up @@ -241,11 +249,11 @@ long bkbase::get_width() {
long bkbase::RectConvert(long& x1, long& y1, long& x2, long& y2) {


if (_pbkdisplay && (_display == RENDER_TYPE::NORMAL || _display == RENDER_TYPE::GDI)) {
/*if (_pbkdisplay && (_display == RENDER_TYPE::NORMAL || _display == RENDER_TYPE::GDI)) {
x1 += _pbkdisplay->_client_x; y1 += _pbkdisplay->_client_y;
x2 += _pbkdisplay->_client_x; y2 += _pbkdisplay->_client_y;
}
}*/

x2 = std::min<long>(this->get_width(), x2);
y2 = std::min<long>(this->get_height(), y2);
Expand Down
4 changes: 2 additions & 2 deletions op/Bkbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class bkbase
std::pair<wstring,wstring> _display_method;
Image _pic;
public:
bkdisplay* _pbkdisplay;
DisplayBase* _pbkdisplay;
bkmouse _bkmouse;
bkkeypad _keypad;
bkkeypad* _keypad;
wstring _curr_path;

};
Expand Down
17 changes: 8 additions & 9 deletions op/Bkgdi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ bkgdi::~bkgdi()
//SAFE_DELETE_ARRAY(_image_data);
}

long bkgdi::Bind(HWND hwnd, long render_type) {
long bkgdi::BindEx(HWND hwnd, long render_type) {
if (!::IsWindow(hwnd))
return 0;
_hwnd = hwnd; _render_type = render_type;
bind_init();
//

if (render_type == RDT_NORMAL) {
RECT rc, rc2;
::GetWindowRect(_hwnd, &rc);
Expand Down Expand Up @@ -72,20 +71,20 @@ long bkgdi::Bind(HWND hwnd, long render_type) {
return 1;
}

long bkgdi::UnBind(HWND hwnd) {
_hwnd = hwnd;
return UnBind();
}
//long bkgdi::UnBind(HWND hwnd) {
// _hwnd = hwnd;
// return UnBind();
//}

long bkgdi::UnBind() {
long bkgdi::UnBindEx() {
//setlog("bkgdi::UnBindEx()");
_hbmpscreen = (HBITMAP)SelectObject(_hmdc, _hbmp_old);
//delete[dwLen_2]hDib;
if (_hdc)DeleteDC(_hdc); _hdc = NULL;
if (_hmdc)DeleteDC(_hmdc); _hmdc = NULL;

if (_hbmpscreen)DeleteObject(_hbmpscreen); _hbmpscreen = NULL;
//if (_hbmp_old)DeleteObject(_hbmp_old); _hbmp_old = NULL;
bkdisplay::bind_release();
return 1;
}

Expand Down
10 changes: 5 additions & 5 deletions op/Bkgdi.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
#define __BKDISPLAY_H_
#include <thread>
#include "optype.h"
#include "bkdisplay.h"
#include "DisplayBase.h"
struct Image;
class bkgdi:public bkdisplay
class bkgdi:public DisplayBase
{
public:
bkgdi();
~bkgdi();
//绑定
long Bind(HWND _hwnd, long render_type) override;
long UnBind(HWND hwnd);
long BindEx(HWND _hwnd, long render_type) override;
//long UnBind(HWND hwnd);
//解绑
long UnBind() override;
long UnBindEx() override;


//long updata_screen();
Expand Down
Loading

0 comments on commit 2c22cab

Please sign in to comment.