示例#1
0
MOboolean moTablet::Finish()
{
	if (Codes!=NULL) {

    for(int i = 0; i < ncodes; i++) Codes[i].DeleteValuesArray();
    delete[] Codes;
    Codes = NULL;
	}
	ncodes = 0;
#ifdef MO_WIN32
	if (t_hTablet)
	{
	    WTClose(t_hTablet);
	}
	#endif
	return true;
}
示例#2
0
BOOL TabletEnd()
//  Tablet context should remain active until the application is closed.
//////////////////////////////////////////////////////////////////////////////
{
    if( hContext )
    {
        WTClose( hContext );
        hContext = NULL;

#ifndef WIN32
        if( Control.bUnlinkWintab )
            _UnlinkWintab();   // free wintab.dll and reset auto-linking
                               // capabilities in Wintabx/Wintab32x.lib
#endif
    }
    return TRUE;
}
示例#3
0
文件: RULE.C 项目: fughz/frayer
/* -------------------------------------------------------------------------- */
LRESULT FAR PASCAL RuleAppWndProc (HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
	static int inMode = ID_CLICK;
	static LONG x1 = 0, x2 = 0, y1 = 0, y2 = 0;
	static HCTX hTab = NULL;

	static FIX32 scale[2];

	PAINTSTRUCT psPaint;
	HDC hDC;

	switch (wMsg) {

		case WM_CREATE:
			TabletScaling(scale);
			break;

		case WM_LBUTTONDOWN:
			if ((hTab = TabletInit(hWnd, scale)) != NULL) {
				PACKET pkt;

				inMode = ID_PRESS;
				InvalidateRect(hWnd, NULL, TRUE);
				UpdateWindow(hWnd);

				while (inMode != ID_CLICK) {

					/* poll */
					if (!WTPacketsGet(hTab, 1, &pkt))
						continue;

					/* handle it */
					if (inMode == ID_PRESS && pkt.pkButtons) {
						x1 = pkt.pkX;
						y1 = pkt.pkY;
						inMode = ID_RELEASE;
						InvalidateRect(hWnd, NULL, TRUE);
						UpdateWindow(hWnd);
					}
					if (inMode == ID_RELEASE && pkt.pkButtons == 0) {
						x2 = pkt.pkX;
						y2 = pkt.pkY;
						inMode = ID_CLICK;
						InvalidateRect(hWnd, NULL, TRUE);
						UpdateWindow(hWnd);
					}
				}
				WTClose(hTab);
			}
			break;

		case WM_PAINT:
			hDC = BeginPaint(hWnd, &psPaint);
			ShowWindow(GetDlgItem(hWnd, ID_CLICK), inMode == ID_CLICK);
			ShowWindow(GetDlgItem(hWnd, ID_PRESS), inMode == ID_PRESS);
			ShowWindow(GetDlgItem(hWnd, ID_RELEASE), inMode == ID_RELEASE);
			if (inMode == ID_CLICK) {
				LONG delta[3];	/* horz/vert/diag */
				int i;

				delta[0] = labs(x2 - x1);
				delta[1] = labs(y2 - y1);
				delta[2] = nsqrt(delta[0] * delta[0] + delta[1] * delta[1]);

				for (i = 0; i < 3; i++) {	 	/* direction */
					char buf[20];

					/* print result in cm */
					wsprintf(buf, "%d.%3.3d", (UINT)delta[i]/1000,
						(UINT)delta[i]%1000);
					SetWindowText(GetDlgItem(hWnd, ID_HC + i), buf);

					/* convert to inches */
					delta[i] = INT(delta[i] * Cm2Inch);

					/* print result in inches */
					wsprintf(buf, "%d.%3.3d", (UINT)delta[i]/1000,
						(UINT)delta[i]%1000);
					SetWindowText(GetDlgItem(hWnd, ID_HI + i), buf);
				}
			}
			EndPaint(hWnd, &psPaint);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		default:
			return DefWindowProc(hWnd, wMsg, wParam, lParam);
	}
	return (LRESULT)0;
}