?? testdlg.cpp
字號:
flag++;
}
//修改最后一個文件的的寬度
header[18] = (unsigned char)(num1 & 0x000000ff);
header[19] = (unsigned char)((num1 >> 8) &0x000000ff);
header[20] = (unsigned char)((num1 >> 16) &0x000000ff);
header[21] = (unsigned char)((num1 >> 24) &0x000000ff);
file_size = (num1) * (num2)*2+Headsize;//修改文件大小
//修改文件大小
header[2] = (unsigned char)(file_size &0x000000ff);
header[3] = (unsigned char)((file_size >> 8) & 0x000000ff);
header[4] = (unsigned char)((file_size >> 16) & 0x000000ff);
header[5] = (unsigned char)((file_size >> 24) & 0x000000ff);
printf("flag=%d\n",flag);
fseek(fp[flag_num-1],0,SEEK_SET);
fwrite(header, sizeof(unsigned char), Headsize, fp[flag_num-1]);
// flag=temp2;
flag=0;
for(temp2=0;temp2<rol_num-1;temp2++)
{
if(width_old%width)
break;
for (i=0;i<height;i++) //寫一排小屏幕的數據
{
for(temp1=0;temp1<cow_num-1;temp1++)
{
fwrite(image, sizeof(unsigned char), width*2, fp[flag]); //BMP圖片數據信息的填寫
image=image+width*2;
flag++;
}
fwrite(image, sizeof(unsigned char), num1*2, fp[flag]); //BMP圖片數據信息的填寫
image=image+num1*2;
flag=flag-(cow_num-1);
}
flag=flag+cow_num;
}
flag=flag_num-cow_num;
for(i=0;i<num2;i++)
{
for(temp1=0;temp1<cow_num-1;temp1++)
{
fwrite(image, sizeof(unsigned char), width*2, fp[flag]); //BMP圖片數據信息的填寫
image=image+width*2;
flag++;
}
fwrite(image, sizeof(unsigned char), num1*2, fp[flag]); //BMP圖片數據信息的填寫
image=image+num1*2;
flag=flag-(cow_num-1);
}
}
}
for(flag=0;flag<flag_num;flag++)
{
fclose(fp[flag]); //關閉文件指針;
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog
CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_bIsCreated=FALSE;
num1=0;
num2=0;
}
void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
//{{AFX_MSG_MAP(CTestDlg)
ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
ON_BN_CLICKED(IDC_BTN_CHANGE, OnBtnChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers
void CTestDlg::OnBtnAdd()
{
// TODO: Add your control notification handler code here
// int num1,num2;
// itoa(num3,ch3,10);
// SetDlgItemText(IDC_EDIT3,ch3);
/* char ch1[10],ch2[10];
GetDlgItemText(IDC_EDIT1,ch1,10);
GetDlgItemText(IDC_EDIT2,ch2,10);
num1=atoi(ch1);
num2=atoi(ch2);
LoadBitmapFile("0913.bmp",10,20,AfxGetMainWnd()->GetSafeHwnd());*/
CFileDialog filedlg(TRUE);
filedlg.m_ofn.lpstrTitle="打開圖片";
filedlg.m_ofn.lpstrFilter="bmp Files(*.bmp)\0*.bmp\0ALL File(*.*)\0*.*\0\0";
if(IDOK==filedlg.DoModal())
{
LoadBitmapFile(filedlg.GetFileName().GetBuffer(NULL),10,25,AfxGetMainWnd()->GetSafeHwnd());
// LoadBitmapFile("1007_0.bmp",10,20,AfxGetMainWnd()->GetSafeHwnd());
}
}
void CTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CString str;
if(GetDlgItemText(IDC_BUTTON1,str),str=="擴展>>")
{
SetDlgItemText(IDC_BUTTON1,"收縮<<");
}
else
{
SetDlgItemText(IDC_BUTTON1,"擴展>>");
}
static CRect rectLarge;
static CRect rectSmall;
if(rectLarge.IsRectNull())
{
CRect rectSeparator;
GetWindowRect(&rectLarge);
GetDlgItem(IDC_SEPERATOR)->GetWindowRect(&rectSeparator);
rectSmall.left=rectLarge.left;
rectSmall.top=rectLarge.top;
rectSmall.right=rectLarge.right;
rectSmall.bottom=rectSeparator.bottom;
}
if(str=="收縮<<")
{
SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),SWP_NOMOVE|SWP_NOZORDER);
}
if(str=="擴展>>")
{
SetWindowPos(NULL,0,0,rectLarge.Width(),rectLarge.Height(),SWP_NOMOVE|SWP_NOZORDER);
}
}
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK();
}
void CTestDlg::OnChangeEdit1()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
WNDPROC prevProc;
LRESULT CALLBACK NewEditProc
(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
if(uMsg==WM_CHAR&&wParam==0x0d)
{
::SetFocus(GetWindow(hwnd,GW_HWNDNEXT));
return 1;
}
else
{
return prevProc(hwnd,uMsg,wParam,lParam);
}
}
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
prevProc=(WNDPROC)SetWindowLong(GetDlgItem(IDC_EDIT1)->m_hWnd,GWL_WNDPROC,(LONG)NewEditProc);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTestDlg::OnBtnChange()
{
// TODO: Add your control notification handler code here
char ch1[10],ch2[10],ch3[10];
unsigned char *image;
GetDlgItemText(IDC_EDIT1,ch1,10);
GetDlgItemText(IDC_EDIT2,ch2,10);
GetDlgItemText(IDC_EDIT5,ch3,10);
num1=atoi(ch1);
num2=atoi(ch2);
BITMAP *bm_new;
// bm_new=LoadBitmapFile("0913.bmp",10,20,AfxGetMainWnd()->GetSafeHwnd());
// num3=(bm_new->bmWidth/num1)*(bm_new->bmHeight/num2);
m=num1; //將對話框里面寬數據取出來
n=num2; //將對話框里面,用戶需要的位圖高數據取出來
// image=bmp_read("0913");
image=bmp_read(ch3);
bmp_write(image);
char local_fname[128];
int k=cow_num;
int position_x=10,position_y=height_old;
for(--flag_num;flag_num>=0;flag_num--)
{
sprintf(local_fname, "%s_%d.bmp", "1007",flag_num);
if(k==1)
{
if((height_old%n)&&(rol_num>height_old/n))
{
position_x=10+num1+5;
LoadBitmapFile(local_fname,position_x,position_y,AfxGetMainWnd()->GetSafeHwnd());
k=cow_num;
rol_num--;
position_y+=height_old%n+5;
continue;
}
position_x=10+num1+5;
LoadBitmapFile(local_fname,position_x,position_y,AfxGetMainWnd()->GetSafeHwnd());
rol_num--;
k=cow_num;
position_y+=num2+5;
continue;
}
position_x=10+k*(num1+5);
LoadBitmapFile(local_fname,position_x,position_y,AfxGetMainWnd()->GetSafeHwnd());
k=k-1;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -