请大家帮个生成ini文件的小忙,送分贴!!!(100)

  • 主题发起人 likingzhe
  • 开始时间
不对的地方帮我指点指点,呵呵。帖子明天结,给各位老大指点江山的时间。在此,非常感谢szhcracker老大的帮忙!
 
晕死,szhcracker老大在呢,呵呵,回复够快啊。。呵呵,我正写感谢语呢,您就来了,哈哈
 
对了,把您的地址给我,我给你邮鸭子,您在北京,我就请您吃饭!
 
看了一下,建议你把一些不用的变量去掉,如 RstList,一些不用的引用去掉,如 Classes, Controls, Dialogs, Forms 等,一些无用的语句去掉,如 RstList := TStringList.Create;这些都是小问题,主要是你在 WM_KEYUP 里面保存 ini 文件,这样如果点击鼠标的话是否会保存?还有就是由于你吧一些代码注释掉了,这将导致按下 ESC 键不会退出。
 
我改了一下,在回调函数中直接保存ini文件,呵呵,可能对电脑的要求比较高了。program MultiTouSDK;uses Windows, Messages, SysUtils, IniFiles;type MTouchPoint = packed record x1: Integer; y1: Integer; x2: Integer; y2: Integer; end;type _TouchData = record dwTouchCount: DWORD; x1: DWORD; y1: DWORD; x2: DWORD; y2: DWORD; end; PointData = array[0..1] of _TouchData;const AppName = 'MultiTouSDK';var AppWnd: HWND; Msg: TMsg; WndClass: TWndClass; gBrBackground: HBRUSH; gCount: Integer = 0; gP1, gP2: MTouchPoint; function StartComDevice(nport: Integer; bTransform: Boolean): Integer; cdecl; external 'MultiTouchSDK.dll'; function RegistCallback(hMultTouchCallBack: PChar): Integer; cdecl; external 'MultiTouchSDK.dll'; function StopComDevice(): Integer; cdecl; external 'MultiTouchSDK.dll';procedure SaveToIniFile(Cont: Integer; mTP: MTouchPoint);begin with TIniFile.Create(ExtractFilePath(ParamStr(0)) + 'ZmRy.ini') do try WriteString('Settings1', '第一点x1', IntToStr(mTP.x1)); WriteString('Settings1', '第一点y1', IntToStr(mTP.x2)); WriteString('Settings1', '第一点x2', IntToStr(mTP.y1)); WriteString('Settings1', '第一点y2', IntToStr(mTP.y2)); finally Free; end;end;function MultTouchCallBack(const pd: PointData; Cnt: Integer): Integer; stdcall; // 用 stdcall 定义回调函数var Rect: TRect; Scx, Scy: Integer;begin Scx := GetSystemMetrics(SM_CXSCREEN); Scy := GetSystemMetrics(SM_CYSCREEN); Rect.Left := 0; Rect.Top := 0; Rect.Right := Scx; Rect.Bottom := Scy; // 注:每个点都有两对坐标,即左上角和右下角坐标 if Cnt > 0 then // Cnt表示触摸的点数,1表示单点点触摸 begin gP1.x1 := pd[0].x1; // 单点触摸时该点的左上角x轴坐标 gP1.x2 := pd[0].x2; // 单点触摸时该点的右下角x轴坐标 gP1.y1 := pd[0].y1; // 单点触摸时该点的左上角y轴坐标 gP1.y2 := pd[0].y2; // 单点触摸时该点的右下角y轴坐标 SaveToIniFile(Cnt, gP1); if Cnt > 1 then begin gP2.x1 := pd[1].x1; // 两点触摸时第二点的左上角x轴坐标 gP2.x2 := pd[1].x2; // 两点触摸时第二点的右下角x轴坐标 gP2.y1 := pd[1].y1; // 两点触摸时第二点的左上角y轴坐标 gP2.y2 := pd[1].y2; // 两点触摸时第二点的右下角y轴坐标 SaveToIniFile(Cnt, gP2); end; end; gCount := Cnt; InvalidateRect(AppWnd, @Rect, False); UpdateWindow(AppWnd); end;function WndProc(Wnd: HWND; Msg, wParam: Word; lParam: LongInt): LongInt; stdcall;var Rect: TRect; Scx, Scy: Integer; DC: HDC; Ps: TPaintStruct; hBrushY, hBrushOld: HBRUSH;begin case Msg of WM_DESTROY: begin StopComDevice(); // 触摸屏停止 PostQuitMessage(0); end; WM_KEYUP: if wParam = VK_ESCAPE then // 按下 ESC 键 begin StopComDevice(); // 触摸屏停止 PostQuitMessage(0); end; WM_COMMAND: if LOWORD(wParam) = WM_CLOSE then DestroyWindow(Wnd); WM_PAINT: begin DC := BeginPaint(Wnd, Ps); Scx := GetSystemMetrics(SM_CXSCREEN); Scy := GetSystemMetrics(SM_CYSCREEN); Rect.Left := 0; Rect.Top := 0; Rect.Right := Scx; Rect.Bottom := Scy; FillRect(DC, Rect, gBrBackground); SetTextColor(DC, RGB(255, 128, 64)); SetBkMode(DC, TRANSPARENT); TextOut(DC, Round(Rect.Right / 2 - 100), 20, 'Please press ESC key to cancel.', 31); hBrushY := CreateSolidBrush(RGB(255, 128, 64)); hBrushOld := HBRUSH(SelectObject(DC, hBrushY)); if gCount > 0 then begin Rect.Left := Round(gP1.x1 * Scx / 4096); Rect.Right := Round(gP1.x2 * Scx / 4096); Rect.Top := Round(gP1.y1 * Scy / 4096); Rect.Bottom := Round(gP1.y2 * Scy / 4096); Ellipse(DC, Rect.Left - 5, Rect.Top - 5, Rect.Right, Rect.Bottom); if gCount > 1 then begin Rect.Left := Round(gP2.x1 * Scx / 4096); Rect.Right := Round(gP2.x2 * Scx / 4096); Rect.Top := Round(gP2.y1 * Scy / 4096); Rect.Bottom := Round(gP2.y2 * Scy / 4096); Ellipse(DC, Rect.Left - 5, Rect.Top - 5, Rect.Right, Rect.Bottom); end; DeleteObject(hBrushY); DeleteObject(hBrushOld); end; EndPaint(Wnd, Ps); end; end; WndProc := DefWindowProc(Wnd, Msg, wParam, lParam);end; begin if FindWindow(AppName, nil) <> 0 then Halt; FillChar(WndClass, SizeOf(WndClass), 0); with WndClass do begin style := CS_HREDRAW or CS_VREDRAW; lpfnWndProc := @WndProc; // 取回调函数 WndProc 的地址 hInstance := SysInit.HInstance; // 实例句柄 hIcon := LoadIcon(hInstance, 'MAINICON'); hCursor := LoadCursor(0, IDC_ARROW); lpszClassName := AppName; // 窗口类名 end; Windows.RegisterClass(WndClass); // 注册窗口类 gBrBackground := CreateSolidBrush(RGB(0, 128, 255)); AppWnd := CreateWindow(AppName, nil, WS_POPUP or WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 0, 0, HInstance, nil); if AppWnd > 0 then begin ShowWindow(AppWnd, SW_NORMAL); UpdateWindow(AppWnd); RegistCallback(@MultTouchCallBack); // 注册回调函数 StartComDevice(0, True); // 启动 COM 口的触摸屏 end; while GetMessage(Msg, 0, 0, 0) do begin TranslateMessage(Msg); DispatchMessage(Msg); end;end.
 
呵呵,老大就是老大,我不佩服都不行。。。
 
呵呵,新的程序,我看了,没问题,呵呵。老大,你的地址!!!鸭子是一定的,不要忽视
 
请老大留下联系方式呦,以后有问题,呵呵,还需要您帮忙的。
 
顶部