DLL接口中传进函数指针
typedef bool ( *FUNC_InsertExcelValue)(AnsiString FieldName,AnsiString Fvalue,bool FIsTitleFlag,bool FIsAppendFlag,bool FIsPostFlag);
引用dll接口的程序中也要加上这个函数声明
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CoInitialize(NULL);
CoInitialize是Windows提供的API函数,用来告诉 Windows以单线程的方式创建com对象,应用程序调用com库函数(除CoGetMalloc和内存分配函数)之前必须初始化com库。
CoUninitialize;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
myCopyDATA.cbData=str.Length();
myCopyDATA.lpData=str.c_str();
SendMessage(wnd,WM_COPYDATA,NULL,(LPARAM)&myCopyDATA);
MESSAGE_HANDLER(WM_COPYDATA, TWMCopyData, fun_copydata)
END_MESSAGE_MAP(TForm)
char* DataBuf;
cds=(COPYDATASTRUCT*)Msg.CopyDataStruct;
DataBuf=new char[100];
memset(DataBuf,0,100);
CopyMemory(DataBuf,cds->lpData,cds->cbData);
AnsiString Str=AnsiString(DataBuf);
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
代码 实现 模拟 键盘按下、弹起 keybd_event(VK_ESCAPE,0,0,0);
keybd_event(VK_ESCAPE,0,KEYEVENTF_KEYUP,0);
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DLL中有Form,如果dll中接口函数传进来调用dll的窗口句柄,如何使dll中的form的窗口的图标和调用者的一致
TMemoryStream *pStream=new TMemoryStream();
pStream->SetSize(1024);
mainApp->Icon->SaveToStream(pStream);
pStream->Seek(0,soFromBeginning);
Application->Icon->LoadFromStream(pStream);
delete pStream;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
关于vector
#include "map.h"
#include “vector.h”
map<int,int> b; b[0]=1;b[1]=2;
map<AnsiString,AnsiString> string; string["wowo"]="peng";string["shishi"]="xiao";
if(string.count("wowo")>0) 可以用来判断索引“wowo”存在否。
vector<AnsiString> a; a.push_back("wo"); ShowMessage(a[0]);或者ShowMessage(a.at(0));
对vector类型进行排序
vector<button*> globalButton;
bool mysort(const button* v1,const button* v2)
{
return v1->designinfo<v2->designinfo;
}
sort(globalButton.begin(),globalButton.end(),mysort);
迭代器
vector<int>::iterator iters;
for(iters=move_designinfo.begin();iters!=move_designinfo.end();++iters)
{
globalEdit.at(*iters)->Style->Shadow=False;
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
改变控件的一些枚举属性
t_TcxTextEdit->Style->TextStyle=TFontStyles()<<fsUnderline<<fsItalic;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
实现对控件的一些交互操作
TControl* control=(TControl*)Sender;
ReleaseCapture(); //释放鼠标监控
control->Perform(WM_SYSCOMMAND,0xF001,0);//左边框可伸缩
control->Perform(WM_SYSCOMMAND,0xF012,0);//控件可拖拽移动
control->Perform(WM_SYSCOMMAND,0xF002,0);//右边框可伸缩
改变鼠标的样式
if (X>=0&&X<=5)
{
control->Cursor=crSizeWE; //向左拉 箭头
}
else if (X>5&&X<control->Width-5)
{
control->Cursor=crHandPoint; //小白手
}
else if (X>=control->Width-5&&X<=control->Width)
{
control->Cursor=crSizeWE; //向右拉 箭头
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
panel控件没有Canvas 画布属性,怎么办?c->Handle=GetDC(mainPanel->Handle);
c->Pen->Color=clDefault;
c->Pen->Style=psDot;
c->MoveTo(start->x,start->y);
c->LineTo(end->x,start->y);
c->LineTo(end->x,end->y);
c->LineTo(start->x,end->y);
c->LineTo(start->x,start->y);
delete c;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
类声明中如果有new出来的成员,要在析构中释放!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
在 Canvas 上画出任意长宽比例,旋转任意角度的,带反走样算法(anti-aliased)的字符串
TCanvas *lpCvs = PaintBox1->Canvas;
HFONT hFnt = CreateFont(
-MulDiv(40,GetDeviceCaps(lpCvs->Handle,LOGPIXELSY),72), //字高40磅
-MulDiv(10,GetDeviceCaps(lpCvs->Handle,LOGPIXELSX),72), //字宽10磅(汉字20磅)
450,450, //旋转 45 度 (可旋转任意角度, 以 1/10 度为单位)
0,0,0,0,
GB2312_CHARSET, //简体中文
0,0,
ANTIALIASED_QUALITY, //使用反走样(anti-aliased)算法
0,
"宋体"); //字体
SelectObject(lpCvs->Handle,hFnt);
SetTextColor(lpCvs->Handle,RGB(0,0,255));
SetBkMode(lpCvs->Handle,TRANSPARENT);
lpCvs->TextOut(0,200,"欢迎访问 C++ 爱好者网站");
lpCvs->TextOut(60,200,"www.cppfans.com");
DeleteObject(hFnt); //释放创建的字体的资源
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------