從網路上找的...

void CXXXDlg::OnPaint()
{
        if (IsIconic())
        {
                CPaintDC dc(this); // 繪製的裝置內容

Joh 發表在 痞客邦 留言(0) 人氣()

1. 在Create() 時的Style要加上 BS_OWNERDRAW
2. 在Class中加上 virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
3. 在cpp 檔中繪製元件 <--- 從網路上找的
void CTvButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
        CDC dc;
        dc.Attach(lpDrawItemStruct->hDC); //Get device context object
        CRect rt;
        rt = lpDrawItemStruct->rcItem; //Get button rect

Joh 發表在 痞客邦 留言(0) 人氣()

用winsock2.h 來建立raw socket一直失敗
後來上網爬文後才發現...
在win7下要用管理者權限開vs2008才可以建立成功...

Joh 發表在 痞客邦 留言(0) 人氣()

#include <windows.h>

#pragma comment( lib, "gdiplus.lib" )
#include <gdiplus.h>

using namespace Gdiplus;

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
{
UINT num = 0; // number of image encoders
UINT size = 0; // size of the image encoder array in bytes

ImageCodecInfo* pImageCodecInfo = NULL;

GetImageEncodersSize(&num, &size);
if(size == 0)
return -1; // Failure

pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
if(pImageCodecInfo == NULL)
return -1; // Failure

GetImageEncoders(num, size, pImageCodecInfo);

for(UINT j = 0; j < num; ++j)
{
if( wcscmp(pImageCodecInfo[j].MimeType, format) == 0 )
{
*pClsid = pImageCodecInfo[j].Clsid;
free(pImageCodecInfo);
return j; // Success
}
}

free(pImageCodecInfo);
return -1; // Failure
}

void Filter( Bitmap* src, Bitmap* dst )
{
int w, h;
w = src->GetWidth();
h = src->GetHeight();

for( int y=0; y<h; y++ ) {
for( int x=0; x<w; x++ ) {
Color c;
c = src->GetPixel( x, y );

// do something interesting here!

dst->SetPixel( x, y, c );
}
}
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR sCmdLine, int nCmdShow )
{
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

Bitmap* pBitmapIn = new Bitmap( L"input.jpg" );

Bitmap* pBitmapOut = new Bitmap( pBitmapIn->GetWidth(), pBitmapIn->GetHeight(), PixelFormat32bppRGB );

Filter( pBitmapIn, pBitmapOut );

CLSID encoderClsid;
GetEncoderClsid(L"image/jpg", &encoderClsid);
pBitmapOut->Save( L"output.jpg", &encoderClsid, 0 );

GdiplusShutdown(gdiplusToken);
return 0;
}

Joh 發表在 痞客邦 留言(0) 人氣()

 
LPPICTURE gpPicture;
void C169Dlg::ShowPicture(CDC *pDC, CString m_strBRoute, int x, int y, int width, int height)
{
HANDLE hFile =CreateFile(m_strBRoute, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
_ASSERTE(INVALID_HANDLE_VALUE != hFile);
//Get File Size
DWORD dwFileSize = GetFileSize(hFile, NULL);
_ASSERTE(-1 != dwFileSize);
LPVOID pvData = NULL;

Joh 發表在 痞客邦 留言(0) 人氣()

簡單小記一下
 
send socket :
1. socket()

Joh 發表在 痞客邦 留言(0) 人氣()

1. 先要有 webbrowser2.cpp/.h 檔
 
2. 在Webbrowser的Dialog加上下列code

BEGIN_MESSAGE_MAP(CWebDlg, CDialog)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_WM_SIZE()
    ON_COMMAND(ID_DEMO_PRINTPREVIEW, OnPrintpreview)
    ON_COMMAND(ID_DEMO_PAGESETUP, OnPagesetup)
END_MESSAGE_MAP()
// CWebDlg 訊息處理常式
BOOL CWebDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
        // Set the icon for this dialog.  The framework does this automatically
    //  when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE);            // Set big icon
    SetIcon(m_hIcon, FALSE);        // Set small icon
    
    // TODO: Add extra initialization here
    CString csAddress("192.168.81.229");
    COleVariant vtEmpty;
    Web.Navigate(csAddress, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
    ReSize();
    return TRUE;
}
void CWebDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
    if (!((nID & 0xFFF0) == IDM_ABOUTBOX))
    {
        CDialog::OnSysCommand(nID, lParam);
    }
}
// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
void CWebDlg::OnPaint()
{
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting
        SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;
        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
}

Joh 發表在 痞客邦 留言(0) 人氣()

這篇也是寫給我自已看的...
 
[製作DLL]
首先,建立一個DLL專案

Joh 發表在 痞客邦 留言(1) 人氣()

跟 c++ 比較不一樣 QQ"
或許是我對Java不了解 ~ 應該還有別的用法
 
 try {
                       

Joh 發表在 痞客邦 留言(0) 人氣()

這也是寫給我自已看的 XDD
 
記得一定要改為String...
 

Joh 發表在 痞客邦 留言(0) 人氣()

Picture control 中顯示 bitmap 的用法 (寫給我自已看的...)
 
1. 拉Picture 元件 並且更改 ID (因預設是用 CStatic,所以要改為別的名字)
 

Joh 發表在 痞客邦 留言(1) 人氣()

Example.JPG
如何在 MFC 中建立一個日曆
 
1. include "afxdtctl.h"   <------- 這個是包含CMonthCalCtrl的header檔
 

Joh 發表在 痞客邦 留言(0) 人氣()

1 2 3
Blog Stats
⚠️

成人內容提醒

本部落格內容僅限年滿十八歲者瀏覽。
若您未滿十八歲,請立即離開。

已滿十八歲者,亦請勿將內容提供給未成年人士。