MFC Dialog Position Save & Load

Programming/MFC 2016. 11. 10. 11:45 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

MFC Dialog Position Save & Load


참조 : http://www.codeproject.com/Articles/1154/Saving-a-windows-size-position-and-state-in-MFC


Saving the window placement








BOOL CMainFrame::DestroyWindow() 
{
    WINDOWPLACEMENT wp;
    GetWindowPlacement(&wp);
    AfxGetApp()->WriteProfileBinary("MainFrame", "WP", (LPBYTE)&wp, sizeof(wp));

    return CMDIFrameWnd::DestroyWindow();
}






Restoring the window placement









void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus) 
{
    CMDIFrameWnd::OnShowWindow(bShow, nStatus);

    static bool bOnce = true;

    if(bShow && !IsWindowVisible()
        && bOnce)
    {
        bOnce = false;

        WINDOWPLACEMENT *lwp;
        UINT nl;

        if(AfxGetApp()->GetProfileBinary("MainFrame", "WP", (LPBYTE*)&lwp, &nl))
        {
            SetWindowPlacement(lwp);
            delete [] lwp;
        }
    }
}







'Programming > MFC' 카테고리의 다른 글

[MFC] Dialog 닫기 (OnOK/EndDialog)  (0) 2017.02.08
CWnd::Invalidate  (0) 2016.11.15
MFC - 다이얼로그 생성시 발생되는 메세지들...  (0) 2016.11.07
MFC x64 ADO msado15.dll  (0) 2016.10.28
x64 ADO import  (0) 2016.10.28

x64 ADO import

Programming/MFC 2016. 10. 28. 16:33 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

ERROR


error C2813: /MP를 지정하면 #import를 사용할 수 없습니다. 

error C2653: 'ADODB' : 클래스 또는 네임스페이스 이름이 아닙니다.


x64 ADO import



ADO 바이너리가 두 군데 나뉘어 배포된다. x32 바이너리는 C:\Program Files (x86)\Common Files\System\ado\에 있고, x64 바이너리는 C:\Program Files\Common Files\System\ado\에 있다. 그러니 ADO를 import할 땐 이런 식으로 하면 된다.




#import "C:\Program Files\Common Files\System\ado\msado15.dll"





#import "C:\Program Files (x86)\Common Files\System\ado\msado15.dll"





#import "libid:EF53050B-882E-4776-B643-EDA472E8E3F2"






x32 x64 상관 없이 돌리려면




#if defined(WIN64)

#import "C:\Program Files\Common Files\System\ado\msado15.dll"

#else

#import "libid:EF53050B-882E-4776-B643-EDA472E8E3F2"

#endif




참조 : https://andromedarabbit.net/wp/unhappy_when_importing_x64_ado/





MSSQL 테이블명, 컬럼명 검색

Programming/MFC 2016. 10. 27. 16:54 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

MSSQL 테이블명, 컬럼명 검색








-- 테이블명 검색

SELECT * FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_NAME = '테이블명'





-- 컬럼명 검색

SELECT * FROM information_schema.COLUMNS WHERE COLUMN_NAME = '컬럼명'





-- PK 검색

SELECT * FROM information_schema.KEY_COLUMN_USAGE

'Programming > MFC' 카테고리의 다른 글

MFC x64 ADO msado15.dll  (0) 2016.10.28
x64 ADO import  (0) 2016.10.28
Visual Studio 2013 클래스뷰, 리소스뷰 가 보이지 않을때  (0) 2016.10.27
CEdit control의 font 바꾸기  (0) 2016.10.25
CTextProgressCtrl hide Edge  (0) 2016.10.25

MFC CGridCtrl Color Change

Programming/MFCGridCtrl 2016. 10. 20. 15:09 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

MFC CGridCtrl Color Change




 





COLORREF ItemBkColour = RGB(255,255,255);

m_Grid.SetItemBkColour(0, 0, ItemBkColour);

m_Grid.SetItemBkColour(0, 1, ItemBkColour);

m_Grid.SetItemBkColour(0, 2, ItemBkColour);

m_Grid.SetItemBkColour(0, 3, ItemBkColour);






m_Grid.SetBkColor(RGB(255, 0, 0)); 






MFC CWnd Control Border Color Change

Programming/MFC 2016. 10. 20. 14:48 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

MFC CWnd Control Border Color Change









CWnd::OnNcPaint

 

게시: 2016년 4월

The framework calls this member function when the nonclient area needs to be painted.

비클라이언트 영역을 그려야 할 때 프레임 워크는이 멤버 함수를 호출 합니다.

afx_msg void OnNcPaint( );

The default implementation paints the window frame.


An application can override this call and paint its own custom window frame. The clipping region is always rectangular, even if the shape of the frame is altered.


기본 구현에서는 창 프레임을 그립니다.


응용 프로그램이이 호출을 무시 하 고 자체 사용자 지정 창 프레임을 페인트할 수 있습니다. 클리핑 영역은 프레임의 모양을 변경 하는 경우에 항상 사각형입니다.



void CDerivedEdit::OnNcPaint() 
{
		CDC* pDC = GetWindowDC( );
		
		//work out the coordinates of the window rectangle,
		CRect rect;
		GetWindowRect( &rect);
		rect.OffsetRect( -rect.left, -rect.top);
		
		//Draw a single line around the outside
		CBrush brush( RGB( 255, 0, 0));
		pDC->FrameRect( &rect, &brush);
		ReleaseDC( pDC);
}


'Programming > MFC' 카테고리의 다른 글

CEdit control의 font 바꾸기  (0) 2016.10.25
CTextProgressCtrl hide Edge  (0) 2016.10.25
MFC CheckBox 컨트롤의 현재 상태  (0) 2016.10.19
MFC Control Color Change  (0) 2016.10.19
MFC Bitmap Button  (0) 2016.10.18

MFC Bitmap Button

Programming/MFC 2016. 10. 18. 13:22 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

MFC Bitmap Button



BitmapButton

ImageButton



1. Button Property


[Owner Draw] : True










2. Add Member Variable









3. Change Member Variable Type



CButton -> CBitmapButton








4. Load Bitmaps









m_Connect_Btn.LoadBitmaps(IDB_BITMAP_CONNECT_RESOURCE, IDB_BITMAP_CONNECT_SEL, IDB_BITMAP_CONNECT_FOCUS, IDB_BITMAP_CONNECT_DISABLED)
m_Connect_Btn.SizeToContent();








Hiredis Subscribe/Publish with CWinThread

Programming/Redis 2016. 10. 5. 14:01 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Hiredis Subscribe/Publish



CWinThread 를 이용한 구현




struct event_base *base = event_base_new();

class CRedisConnect : public CWinThread
{
public:
	redisAsyncContext *c;
	// CWinThread extends
	virtual BOOL InitInstance();
	virtual int Run();
};

BOOL CRedisConnect::InitInstance()
{
	return TRUE;
}

int CRedisConnect::Run()
{
	c = redisAsyncConnect(redisServerIP, redisServerPort);
	if (c->err) {
		/* Let *c leak for now... */
		return 1;
	}
	redisLibeventAttach(c, base);

	int re2 = redisAsyncCommand(c, getCallback, NULL, "SUBSCRIBE foo");

	event_base_dispatch(base);

	return (0);
}



void getCallback(redisAsyncContext *c, void *r, void *privdata) {

	redisReply *reply = (redisReply *)r;
	if (reply == NULL)
	{
		LOG4CXX_DEBUG(g_log, "Subcribe reply == NULL");
	}
	// reply->type
	// #define REDIS_REPLY_STRING 1
	// #define REDIS_REPLY_ARRAY 2
	// #define REDIS_REPLY_INTEGER 3
	// #define REDIS_REPLY_NIL 4
	// #define REDIS_REPLY_STATUS 5
	// #define REDIS_REPLY_ERROR 6
	else if (reply->type == REDIS_REPLY_ERROR)
	{
		LOG4CXX_DEBUG(g_log, "Subcribe reply type == REDIS_REPLY_ERROR");
	}
	else if (reply->type == REDIS_REPLY_ARRAY)
	{
		LOG4CXX_DEBUG(g_log, "reply->elements == " << reply->elements);
		LOG4CXX_DEBUG(g_log, "reply->len == " << reply->len);
		for (int i = 0; i < reply->elements; i++)
		{
			if (reply->element[i]->str != NULL)
			LOG4CXX_DEBUG(g_log, "Subcribe reply array [" << i << "] == " << reply->element[i]->str);			
		}		
	}
	else
	{
		LOG4CXX_DEBUG(g_log, "getCallback reply str : " << reply->str);
	}
}

'Programming > Redis' 카테고리의 다른 글

Hiredis SMEMBERS 활용  (0) 2017.01.24
Redis Client Connect Test  (0) 2016.10.26
How to use Pub/sub with hiredis in C++?  (0) 2016.09.29
hiredis fatal error C1853:  (0) 2016.09.29
hiredis MFC import Visual Studio 2013  (0) 2016.09.28

How to use Pub/sub with hiredis in C++?

Programming/Redis 2016. 9. 29. 14:06 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

example for pub/sub



https://github.com/redis/hiredis/issues/55 aluiken commented on Mar 2, 2012




void onMessage(redisAsyncContext *c, void *reply, void *privdata) {
    redisReply *r = reply;
    if (reply == NULL) return;

    if (r->type == REDIS_REPLY_ARRAY) {
        for (int j = 0; j < r->elements; j++) {
            printf("%u) %s\n", j, r->element[j]->str);
        }
    }
}

int main (int argc, char **argv) {
    signal(SIGPIPE, SIG_IGN);
    struct event_base *base = event_base_new();

    redisAsyncContext *c = redisAsyncConnect("127.0.0.1", 6379);
    if (c->err) {
        printf("error: %s\n", c->errstr);
        return 1;
    }

    redisLibeventAttach(c, base);
    redisAsyncCommand(c, onMessage, NULL, "SUBSCRIBE testtopic");
    event_base_dispatch(base);
    return 0;
}

'Programming > Redis' 카테고리의 다른 글

Redis Client Connect Test  (0) 2016.10.26
Hiredis Subscribe/Publish with CWinThread  (0) 2016.10.05
hiredis fatal error C1853:  (0) 2016.09.29
hiredis MFC import Visual Studio 2013  (0) 2016.09.28
Windows7 Redis 설치 및 실행  (0) 2016.09.27

hiredis MFC import Visual Studio 2013

Programming/Redis 2016. 9. 28. 11:49 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

hiredis MFC import




Hiredis is a minimalistic C client library for the Redis database.

It is minimalistic because it just adds minimal support for the protocol, but at the same time it uses a high level printf-alike API in order to make it much higher level than otherwise suggested by its minimal code base and the lack of explicit bindings for every Redis command.


1. Download Hiredis

Project Site : https://github.com/redis/hiredis


[Clone or download] [Download ZIP]




2. Include Hiredis Header Files



3. Config Hiredis Header Files Path







4. Build Hiredis Library File


Open Hiredis Project





Build Hiredis Project





5. Config Hiredis Library File Path





6. Sample Code




#include 
#include 
#include 

#include "hiredis.h"

#ifdef HIREDIS_WIN
#define snprintf sprintf_s
#endif

int main(void) {
    unsigned int j;
    redisContext *c;
    redisReply *reply;

    struct timeval timeout = { 1, 500000 }; // 1.5 seconds
    c = redisConnectWithTimeout((char*)"127.0.0.1", 6379, timeout);
    if (c->err) {
        printf("Connection error: %s\n", c->errstr);
        exit(1);
    }

    /* PING server */
    reply = redisCommand(c,"PING");
    printf("PING: %s\n", reply->str);
    freeReplyObject(reply);

    /* Set a key */
    reply = redisCommand(c,"SET %s %s", "foo", "hello world");
    printf("SET: %s\n", reply->str);
    freeReplyObject(reply);

    /* Set a key using binary safe API */
    reply = redisCommand(c,"SET %b %b", "bar", 3, "hello", 5);
    printf("SET (binary API): %s\n", reply->str);
    freeReplyObject(reply);

    /* Try a GET and two INCR */
    reply = redisCommand(c,"GET foo");
    printf("GET foo: %s\n", reply->str);
    freeReplyObject(reply);

    reply = redisCommand(c,"INCR counter");
    printf("INCR counter: %lld\n", reply->integer);
    freeReplyObject(reply);
    /* again ... */
    reply = redisCommand(c,"INCR counter");
    printf("INCR counter: %lld\n", reply->integer);
    freeReplyObject(reply);

    /* Create a list of numbers, from 0 to 9 */
    reply = redisCommand(c,"DEL mylist");
    freeReplyObject(reply);
    for (j = 0; j < 10; j++) {
        char buf[64];

        snprintf(buf,64,"%d",j);
        reply = redisCommand(c,"LPUSH mylist element-%s", buf);
        freeReplyObject(reply);
    }

    /* Let's check what we have inside the list */
    reply = redisCommand(c,"LRANGE mylist 0 -1");
    if (reply->type == REDIS_REPLY_ARRAY) {
        for (j = 0; j < reply->elements; j++) {
            printf("%u) %s\n", j, reply->element[j]->str);
        }
    }
    freeReplyObject(reply);

    return 0;
}


7. Sample Monitor






'Programming > Redis' 카테고리의 다른 글

Redis Client Connect Test  (0) 2016.10.26
Hiredis Subscribe/Publish with CWinThread  (0) 2016.10.05
How to use Pub/sub with hiredis in C++?  (0) 2016.09.29
hiredis fatal error C1853:  (0) 2016.09.29
Windows7 Redis 설치 및 실행  (0) 2016.09.27

openssl AES encrypt (AES_ctr128_encrypt)

Programming/C,CPP,CS 2016. 9. 19. 08:50 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

openssl AES encrypt (AES_ctr128_encrypt)



Sample Class













AESCTR.cppAESCTR.h