TOOLBOX.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX - Modelling, Animation and Rendering Package
00003 -- */
00004 
00005 
00006 /* file TOOLBOX .C */
00007 
00008 // Handles the user interface code to draw the tool pannel
00009 // and handle its window function. It also handles the coordinates
00010 // floating pannel and the maps / lock etc. pannel
00011 
00012 #define MODULE_TOOLBOX 1
00013 
00014 #include "design.h"
00015 
00016 #define NO_MESSAGE -1
00017 #define NO_HELP    -1
00018 
00019 typedef struct tagTOOL_STRUCT{
00020  long  Message,Help,Tip;
00021 } TOOL_STRUCT;
00022 
00023 extern HBITMAP hBmBackground;
00024 
00025 #define LARGE_TOOL_X 50
00026 #define LARGE_TOOL_Y 40
00027 #define SMALL_TOOL_X 32
00028 #define SMALL_TOOL_Y 32
00029 #define N_ICONS      12
00030 
00031 static HBITMAP hBitmapB=NULL,
00032                hBitmapH=NULL,
00033                hBitmapD=NULL,
00034                hBitmapA=NULL,
00035                hBitmapI=NULL,
00036                hBitmapM=NULL;
00037 static BOOL    tools_enable=TRUE;
00038 static long    cxToolBtn,cyToolBtn;
00039 static char    szToolsClass[]="OFX:AnimatorToolsClass";
00040 static LRESULT CALLBACK ToolsWndProc(HWND,UINT,WPARAM,LPARAM);
00041 static TOOL_STRUCT aTools[N_ICONS]={
00042   IDM_STOP,                IDI_OBJECT_SELECTOR,           IDI_TIP_T_1,
00043   IDM_TOOLS_NODE,          IDI_VERTEX_SELECTOR,           IDI_TIP_T_2,
00044   IDM_TOOLS_SELECTOR,      IDI_SELECT_SELECTOR,           IDI_TIP_S_1,
00045   IDM_TOOLS_PAN,           IDI_PAN,                       IDI_TIP_T_3,
00046   IDM_TOOLS_ZOOMIN,        IDI_ZOOM,                      IDI_TIP_T_4,
00047   IDM_TOOLS_GRABBER,       IDI_TOOLS_GRABBER,             IDI_TIP_T_5,
00048   IDM_TOOLS_ROTATOR,       IDI_TOOLS_ROTATOR,             IDI_TIP_T_6,
00049   IDM_TOOLS_EXPANDER,      IDI_TOOLS_EXPANDER,            IDI_TIP_T_7,
00050   IDM_TOOLS_PLOTTER,       IDI_TOOLS_PLOTTER,             IDI_TIP_T_8,
00051   IDM_TOOLS_MAGNET_ATTRACT,IDI_TOOLS_MAGNET_ATTRACT,      IDI_TIP_T_A,
00052   IDM_PRIMITIVE_QADD,      IDI_TOOLS_QPRIMITIVES,         IDI_TIP_T_B,
00053   IDM_VIEW_RENDER,         IDI_CONTROL_RENDER,            IDI_TIP_A_1
00054 };
00055 
00056 static void ToolboxCreate(void);
00057 static void PannelSelectTool(HWND hwnd, int *oldtool, int newtool);
00058 static void DoAddTooltip(HWND hwndOwner, HWND tipon, int resid);
00059 static HWND DoCreateTooltip(HWND hwndOwner);
00060 
00061 
00062 void ToolboxShow(BOOL fShow){
00063  if(ghwndTools == NULL)ToolboxCreate();
00064 }
00065 
00066 void ToolboxDestroy(void){
00067  if(ghwndCoord1)DestroyWindow(ghwndCoord1);
00068  if(ghwndLock)DestroyWindow(ghwndLock);
00069 }
00070 
00071 void EnableTools(BOOL status){
00072   tools_enable=status;
00073   InvalidateRect(ghwndTools,NULL,FALSE);
00074 }
00075 
00076 void MoveToolsWindow(void){
00077  int i,x,y;
00078  RECT rc1;
00079  POINT pt;
00080  if(ghwndTools == NULL)return;
00081  GetWindowRect(ghwnd_view,&rc1);
00082  if(bToolpannelLeft)x=WindowGap;
00083  else x=rc1.right+3;
00084  y=rc1.top;
00085  pt.x=x; pt.y=y;
00086  ScreenToClient(ghwnd_main,&pt);
00087  x=pt.x; y=pt.y;
00088  for(i=0;i<N_ICONS;i++){
00089    MoveWindow(GetDlgItem(ghwndTools,i),
00090               0,cyToolBtn*i,cxToolBtn,cyToolBtn,FALSE);
00091  }
00092  MoveWindow(ghwndTools,x,y,cxToolBtn,cyToolBtn*N_ICONS,TRUE);
00093 }
00094 
00095 void ChangeToolboxBitmaps(void){
00096  if(hBitmapB != NULL)DeleteObject(hBitmapB);  hBitmapB=NULL;
00097  if(hBitmapH != NULL)DeleteObject(hBitmapH);  hBitmapH=NULL;
00098  if(hBitmapD != NULL)DeleteObject(hBitmapD);  hBitmapD=NULL;
00099  if(hBitmapA != NULL)DeleteObject(hBitmapA);  hBitmapA=NULL;
00100  if(hBitmapI != NULL)DeleteObject(hBitmapI);  hBitmapI=NULL;
00101  if(hBitmapM != NULL)DeleteObject(hBitmapM);  hBitmapM=NULL;
00102  if(bToolpannelSmall){
00103    cxToolBtn=SMALL_TOOL_X;
00104    cyToolBtn=SMALL_TOOL_Y;
00105    hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_B));
00106    hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_H));
00107    hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_D));
00108    hBitmapA=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_A));
00109    hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_I));
00110    hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_M));
00111  }
00112  else{
00113    cxToolBtn=LARGE_TOOL_X;
00114    cyToolBtn=LARGE_TOOL_Y;
00115    hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_B));
00116    hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_H));
00117    hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_D));
00118    hBitmapA=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_A));
00119    hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_I));
00120    hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_M));
00121  }
00122 }
00123 
00124 static long GetWhichButton(void){
00125   long  i,button_index = -1;
00126   POINT pt;
00127   RECT  rc;
00128   GetCursorPos(&pt);
00129   for(i=0;i<N_ICONS;i++){
00130     GetWindowRect(GetDlgItem(ghwndTools,i),&rc);
00131     if(PtInRect(&rc,pt))button_index=i;
00132   }
00133   return button_index;
00134 }
00135 
00136 static void ToolboxCreate(void){
00137  char title[256];
00138  int x,y;
00139  RECT rc,rc1;
00140  POINT pt;
00141 // if(Preferences.tooltips){
00142  if((ghwndTooltip=DoCreateTooltip(ghwnd_main)) == NULL)return;
00143  SetWindowPos(ghwndTooltip,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
00144  SendMessage(ghwndTooltip,TTM_ACTIVATE,(WPARAM)Preferences.tooltips,0);
00145 // }
00146  GetWindowRect(ghwnd_view,&rc1);
00147  if(bToolpannelLeft)x=WindowGap;
00148  else x=rc1.right+3;
00149  y=rc1.top;
00150  pt.x=x; pt.y=y;
00151  ScreenToClient(ghwnd_main,&pt);
00152  x=pt.x; y=pt.y;
00153  if(bToolpannelSmall){
00154    cxToolBtn=SMALL_TOOL_X;
00155    cyToolBtn=SMALL_TOOL_Y;
00156  }
00157  else{
00158    cxToolBtn=LARGE_TOOL_X;
00159    cyToolBtn=LARGE_TOOL_Y;
00160  }
00161  ghwndTools=CreateWindowEx(
00162                          WS_EX_TRANSPARENT,
00163                          szToolboxClass,NULL,
00164                          WS_CHILD | !WS_BORDER | WS_VISIBLE,
00165                          x,y,
00166                          cxToolBtn,cyToolBtn*N_ICONS,
00167                          ghwnd_main,
00168                          (HMENU)101,
00169                          ghinst_main,NULL);
00170  ghwndCoord1=CreateDialog(ghinst_main,MAKEINTRESOURCE(DLG_COORDS),
00171                           ghwnd_main,(DLGPROC)CoordinatesDlgProc);
00172  ghwndLock=CreateDialog(ghinst_main,MAKEINTRESOURCE(DLG_LOCK),
00173                         ghwnd_main,(DLGPROC)LockDlgProc);
00174  return;
00175 }
00176 
00177 LRESULT CALLBACK ToolboxWndProc(HWND hwnd,UINT msg,
00178                                 WPARAM wParam,LPARAM lParam){
00179  long i;
00180  HWND hWndChild;
00181  switch (msg) {
00182    case WM_CREATE:
00183      if(bToolpannelSmall){
00184        hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_B));
00185        hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_H));
00186        hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_D));
00187        hBitmapA=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_A));
00188        hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_I));
00189        hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_STOOLBAR_M));
00190      }
00191      else{
00192        hBitmapB=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_B));
00193        hBitmapH=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_H));
00194        hBitmapD=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_D));
00195        hBitmapA=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_A));
00196        hBitmapI=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_I));
00197        hBitmapM=LoadBitmap(ghinst_main,MAKEINTRESOURCE(IDBM_TOOLBAR_M));
00198      }
00199      for(i=0;i<N_ICONS;i++){
00200        hWndChild=CreateWindowEx(
00201                               WS_EX_TRANSPARENT,
00202                               szToolBtnClass,NULL,
00203                               WS_CHILD | WS_VISIBLE,
00204                               0,cyToolBtn*i,
00205                               cxToolBtn,cyToolBtn,
00206                               hwnd,(HMENU)i,
00207                               ghinst_main,NULL);
00208        DoAddTooltip(ghwnd_main,hWndChild,aTools[i].Tip);
00209      }
00210      break;
00211    case WM_DESTROY:
00212      if(hBitmapB != NULL)DeleteObject(hBitmapB);  hBitmapB=NULL;
00213      if(hBitmapH != NULL)DeleteObject(hBitmapH);  hBitmapH=NULL;
00214      if(hBitmapD != NULL)DeleteObject(hBitmapD);  hBitmapD=NULL;
00215      if(hBitmapA != NULL)DeleteObject(hBitmapA);  hBitmapA=NULL;
00216      if(hBitmapI != NULL)DeleteObject(hBitmapI);  hBitmapI=NULL;
00217      if(hBitmapM != NULL)DeleteObject(hBitmapM);  hBitmapM=NULL;
00218      break;
00219    default:
00220      return DefWindowProc(hwnd, msg, wParam, lParam);
00221  }
00222  return 0;
00223 }
00224 
00225 LRESULT CALLBACK ToolBtnWndProc(HWND hwnd,UINT msg,
00226                                 WPARAM wParam,LPARAM lParam){
00227  static int  toolTimer = -1, down_tool;
00228  static BOOL bCaptured=FALSE,bCancel=FALSE,bLastCancel=FALSE,bBusy=FALSE;
00229  long w,wold,hid;
00230  MSG mmsg;
00231  mmsg.hwnd=hwnd;
00232  mmsg.message=msg;
00233  mmsg.wParam=wParam;
00234  mmsg.lParam=lParam;
00235  hid=(int)GetWindowLong(hwnd,GWL_ID);
00236  switch (msg) {
00237    case WM_TIMER:
00238      if(bBusy || toolTimer < 0)break;
00239      bBusy=TRUE;
00240      w=GetWhichButton();
00241      if(w < 0 && toolTimer >= 0){
00242        KillTimer(hwnd,toolTimer);
00243        toolTimer = -1;
00244      }
00245      if( w < 0 && gCurTool >= 0){
00246        wold=gCurTool;
00247        gCurTool= -1;
00248        InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00249      }
00250      bBusy=FALSE;
00251      break;
00252    case WM_SETCURSOR:{
00253        hid=aTools[hid].Help;
00254        if(current_message != hid){
00255          if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00256          else{
00257            SendIconHelpMessage(hid);
00258          }
00259        }
00260        current_message=hid;
00261      }
00262      return DefWindowProc(hwnd,msg,wParam,lParam);
00263    case WM_MOUSEMOVE:
00264      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00265      w=GetWhichButton();
00266      if(bCaptured){
00267        if(w == hid)bCancel=FALSE;
00268        else        bCancel=TRUE;
00269        if(bCancel != bLastCancel)InvalidateRect(hwnd,NULL,FALSE);
00270        bLastCancel=bCancel;
00271      }
00272      else{
00273        wold=gCurTool;
00274        gCurTool=w;
00275        if(wold != w){
00276          if(wold >= 0 && wold  < N_ICONS)
00277            InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00278          if(gCurTool >= 0 && gCurTool < N_ICONS)
00279            InvalidateRect(GetDlgItem(ghwndTools,gCurTool),NULL,FALSE);
00280        }
00281        if(toolTimer < 0)toolTimer=SetTimer(hwnd,100,500,NULL);
00282      }
00283      break;
00284    case WM_LBUTTONDBLCLK:
00285      w=GetWhichButton();
00286      if(w == 2)PostMessage(ghwnd_main,WM_COMMAND,IDM_TOOLS_DESELECTOR,0);
00287      if(w == 3)PostMessage(ghwnd_main,WM_COMMAND,IDM_ZOOM_CENTRE,0);
00288      if(w == 4)PostMessage(ghwnd_main,WM_COMMAND,IDM_VIEW_FULL,0);
00289      if(w == 5)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTIONS_MOVE,0);
00290      if(w == 6)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTIONS_ROTATE_CLOCKWISE,0);
00291      if(w == 7)PostMessage(ghwnd_main,WM_COMMAND,IDM_ACTIONS_EXPAND,0);
00292      if(w == 8)PostMessage(ghwnd_main,WM_COMMAND,IDM_TOOLS_PLOT3D,0);
00293      if(w == 9)PostMessage(ghwnd_main,WM_COMMAND,IDM_TOOLS_SHAPER,0);
00294      break;
00295    case WM_LBUTTONDOWN:
00296      if(toolTimer >= 0)KillTimer(hwnd,toolTimer); toolTimer = -1;
00297      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00298      bCaptured=TRUE;
00299      bCancel=bLastCancel=FALSE;
00300      down_tool=hid;
00301      SetCapture(hwnd);
00302      InvalidateRect(hwnd,NULL,FALSE);
00303      break;
00304    case WM_LBUTTONUP:
00305      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,0,(LPARAM)(LPMSG)&mmsg);
00306      ReleaseCapture();
00307      w=GetWhichButton();
00308      bCaptured=FALSE;
00309      if(w < 0 && gCurTool >= 0){
00310        wold=gCurTool;
00311        gCurTool = -1;
00312        InvalidateRect(GetDlgItem(ghwndTools,wold),NULL,FALSE);
00313      }
00314      InvalidateRect(hwnd,NULL,FALSE);
00315      if(down_tool == w && aTools[down_tool].Message != NO_MESSAGE)
00316        PostMessage(ghwnd_main,WM_COMMAND,aTools[w].Message,0);
00317      gCurTool= -1;
00318      break;
00319    case WM_RBUTTONDOWN:{
00320        POINT pt;
00321        HMENU hMenu=LoadMenu(ghinst_main,"ToolbarPopupMenu");
00322        if(hMenu == NULL)break;
00323        pt.x=LOWORD(lParam);
00324        pt.y=HIWORD(lParam);
00325        ClientToScreen(hwnd,&pt);
00326        if(bToolpannelLeft)
00327          CheckMenuItem(hMenu,IDM_CONTEXT_TOOLSLEFT,MF_CHECKED);
00328        if(bToolpannelSmall)
00329          CheckMenuItem(hMenu,IDM_CONTEXT_TOOLSSMALL,MF_CHECKED);
00330        TrackPopupMenu(GetSubMenu(hMenu,0),TPM_LEFTALIGN | TPM_LEFTBUTTON,
00331                       pt.x,pt.y,0,ghwnd_main,NULL);
00332        DestroyMenu(hMenu);
00333      }
00334      break;
00335    case WM_PAINT:{
00336        HDC hDC;
00337        PAINTSTRUCT ps;
00338        hDC=BeginPaint(hwnd,&ps);
00339        if(hBitmapB != NULL && hBitmapD != NULL  && hBitmapH != NULL){
00340          HDC hMemDC;
00341          HBITMAP hbmOld;
00342          BOOL blit=FALSE;
00343          hMemDC = CreateCompatibleDC(hDC);
00344          if(!tools_enable){
00345            hbmOld = SelectObject(hMemDC,hBitmapI);
00346            blit=TRUE;
00347          }
00348          else if ((hwnd == GetCapture() && !bCancel)  ||
00349                   FALSE){
00350            if( (tool == PLOT3D     && hid == 8)      ||
00351                (tool == DESELECTOR && hid == 2)      ||
00352                (tool == SHAPER     && hid == 9))
00353                 hbmOld = SelectObject(hMemDC,hBitmapA);
00354            else hbmOld = SelectObject(hMemDC,hBitmapD);
00355          }
00356          else if( (tool == NOTOOL     && hid == 0)      ||
00357                   (tool == NODETOOL   && hid == 1)      ||
00358                   (tool == SELECTOR   && hid == 2)      ||
00359                   (tool == PAN        && hid == 3)      ||
00360                   (tool == INZOOM     && hid == 4)      ||
00361                   (tool == GRABBER    && hid == 5)      ||
00362                   (tool == ROTATOR    && hid == 6)      ||
00363                   (tool == EXPANDER   && hid == 7)      ||
00364                   (tool == PLOTTER    && hid == 8)      ||
00365                   (tool == MAGNETTO   && hid == 9)      ||
00366                   FALSE)
00367            hbmOld = SelectObject(hMemDC,hBitmapD);
00368          else if( (tool == PLOT3D     && hid == 8)      ||
00369                   (tool == DESELECTOR && hid == 2)      ||
00370                   (tool == SHAPER     && hid == 9))
00371            hbmOld = SelectObject(hMemDC,hBitmapA);
00372          else if(hid == gCurTool)
00373            hbmOld = SelectObject(hMemDC,hBitmapH);
00374          else{
00375            hbmOld = SelectObject(hMemDC,hBitmapB);
00376            blit=TRUE;
00377          }
00378          if(hBmBackground == NULL)blit=FALSE;
00379          if(blit){
00380            HDC hdc_view;
00381            RECT rc;
00382            POINT pp;
00383            BITMAP bm;
00384            HBITMAP hbm_view,hbmoldv;
00385            hbm_view=CreateCompatibleBitmap(hMemDC,cxToolBtn,cyToolBtn);
00386            hdc_view=CreateCompatibleDC(hMemDC);
00387            hbmoldv=SelectObject(hdc_view,hbm_view);
00388            GetWindowRect(hwnd,&rc);
00389            pp.x=rc.left; pp.y=rc.top;
00390            ScreenToClient(ghwnd_main,&pp);
00391            GetObject(hBmBackground,sizeof(BITMAP),&bm);
00392            pp.x = pp.x % bm.bmWidth;
00393            pp.y = pp.y % bm.bmHeight;
00394            SelectObject(hMemDC,hBmBackground);
00395            if(pp.y + cyToolBtn > bm.bmHeight){
00396              if(pp.x + cxToolBtn > bm.bmWidth){
00397                BitBlt(hDC,
00398                   0,0,
00399                   bm.bmWidth -pp.x,
00400                   bm.bmHeight-pp.y,
00401                   hMemDC,
00402                   pp.x,pp.y,
00403                   SRCCOPY);
00404                BitBlt(hDC,
00405                   bm.bmWidth-pp.x,bm.bmHeight-pp.y,
00406                   cxToolBtn - (bm.bmWidth -pp.x),
00407                   cyToolBtn - (bm.bmHeight-pp.y),
00408                   hMemDC,
00409                   (pp.x + (bm.bmWidth -pp.x)) % bm.bmWidth,
00410                   (pp.y + (bm.bmHeight-pp.y)) % bm.bmHeight,
00411                   SRCCOPY);
00412              }
00413              else{
00414                BitBlt(hDC,
00415                   0,0,
00416                   cxToolBtn,
00417                   bm.bmHeight-pp.y,
00418                   hMemDC,
00419                   pp.x,pp.y,
00420                   SRCCOPY);
00421                BitBlt(hDC,
00422                   0,bm.bmHeight-pp.y,
00423                   cxToolBtn,
00424                   cyToolBtn - (bm.bmHeight-pp.y),
00425                   hMemDC,
00426                   pp.x,(pp.y + (bm.bmHeight-pp.y)) % bm.bmHeight,
00427                   SRCCOPY);
00428              }
00429            }
00430            else if(pp.x + cxToolBtn > bm.bmWidth){
00431              BitBlt(hDC,
00432                   0,0,
00433                   bm.bmWidth -pp.x,
00434                   cyToolBtn,
00435                   hMemDC,
00436                   pp.x,pp.y,
00437                   SRCCOPY);
00438              BitBlt(hDC,
00439                   bm.bmWidth-pp.x,0,
00440                   cxToolBtn - (bm.bmWidth -pp.x),
00441                   cyToolBtn,
00442                   hMemDC,
00443                   (pp.x + (bm.bmWidth -pp.x)) % bm.bmWidth,pp.y,
00444                   SRCCOPY);
00445            }
00446            else BitBlt(hDC,
00447                   0,0,
00448                   cxToolBtn,
00449                   cyToolBtn,
00450                   hMemDC,
00451                   pp.x,pp.y,
00452                   SRCCOPY);
00453            SelectObject(hMemDC,hBitmapM);
00454            BitBlt(hDC,
00455                   0,0,
00456                   cxToolBtn,
00457                   cyToolBtn,
00458                   hMemDC,
00459                   0,hid*cyToolBtn,
00460                   0x00220326); // DSna
00461            if(tools_enable)SelectObject(hMemDC,hBitmapB);
00462            else            SelectObject(hMemDC,hBitmapI);
00463            BitBlt(hdc_view,
00464                   0,0,
00465                   cxToolBtn,
00466                   cyToolBtn,
00467                   hMemDC,
00468                   0,hid*cyToolBtn,
00469                   SRCCOPY);
00470            SelectObject(hMemDC,hBitmapM);
00471            BitBlt(hdc_view,
00472                   0,0,
00473                   cxToolBtn,
00474                   cyToolBtn,
00475                   hMemDC,
00476                   0,hid*cyToolBtn,
00477                   SRCAND);
00478            BitBlt(hDC,
00479                   0,0,
00480                   cxToolBtn,
00481                   cyToolBtn,
00482                   hdc_view,
00483                   0,0,
00484                   SRCPAINT);
00485            SelectObject(hdc_view,hbmoldv);
00486            DeleteObject(hbm_view);
00487            DeleteDC(hdc_view);
00488          }
00489          else BitBlt(hDC,
00490                   0,0,
00491                   cxToolBtn,
00492                   cyToolBtn,
00493                   hMemDC,
00494                   0,hid*cyToolBtn,
00495                   SRCCOPY);
00496          SelectObject(hMemDC,hbmOld);
00497          DeleteDC(hMemDC);
00498        }
00499        EndPaint(hwnd,&ps);
00500      }
00501      break;
00502    default:
00503      return DefWindowProc(hwnd,msg,wParam,lParam);
00504  }
00505  return 0;
00506 }
00507 
00508 void ToolboxSetPosition(int w){
00509 }
00510 
00512 
00513 static void DrawQtBtn(BOOL selected,HDC hDC, LPRECT lprc, HBITMAP hbm){
00514  HDC hMemDC;
00515  BITMAP  bmp;
00516  HBITMAP hbmOld;
00517  HBRUSH holdbrush,hbrushFace;
00518  HPEN   holdpen,hpenShadow,hpenHighlight;
00519  int x,y,cx,cy;
00520  hbrushFace=CreateSolidBrush(RGB(192,192,192));
00521  holdbrush=SelectObject(hDC,hbrushFace);
00522  hpenShadow=CreatePen(PS_SOLID,0,RGB(128,128,128));
00523  hpenHighlight=CreatePen(PS_SOLID,0,RGB(255,255,255));
00524  holdpen=SelectObject(hDC,GetStockObject(BLACK_PEN));
00525  Rectangle(hDC,0,0,lprc->right+1,lprc->bottom);
00526  SelectObject(hDC,hpenShadow);
00527  if(selected){
00528    MoveToEx(hDC,1,lprc->bottom-2,NULL);
00529    LineTo(hDC,1,1);
00530    LineTo(hDC,lprc->right-1,1);
00531  }
00532  else{
00533    MoveToEx(hDC,1,lprc->bottom-2,NULL);
00534    LineTo(hDC,lprc->right-1,lprc->bottom-2);
00535    LineTo(hDC,lprc->right-1,1);
00536    MoveToEx(hDC,2,lprc->bottom-3,NULL);
00537    LineTo(hDC,lprc->right-2,lprc->bottom-3);
00538    LineTo(hDC,lprc->right-2,3);
00539    SelectObject(hDC,hpenHighlight);
00540    MoveToEx(hDC,1,lprc->bottom-3,NULL);
00541    LineTo(hDC,1,1);
00542    LineTo(hDC,lprc->right-1,1);
00543    MoveToEx(hDC,2,lprc->bottom-4,NULL);
00544    LineTo(hDC,2,2);
00545    LineTo(hDC,lprc->right-2,2);
00546  }
00547  SelectObject(hDC,holdpen);
00548  DeleteObject(hpenShadow);
00549  DeleteObject(hpenHighlight);
00550  SelectObject(hDC,holdbrush);
00551  DeleteObject(hbrushFace);
00552  if(hbm == NULL)return;
00553  GetObject(hbm,sizeof(BITMAP),&bmp);
00554  cx = bmp.bmWidth;
00555  cy = bmp.bmHeight;
00556  x=max(0,(lprc->right-cx)/2); y=max(0,(lprc->bottom-cy)/2)+1;
00557  if(selected){x++; y++;}
00558  hMemDC = CreateCompatibleDC(hDC);
00559  hbmOld = SelectObject(hMemDC, hbm);
00560  BitBlt(hDC,x,y,cx,cy,hMemDC,0,0,SRCAND);
00561  SelectObject(hMemDC, hbmOld);
00562  DeleteDC(hMemDC);
00563 }
00564 
00565 static void GetFormatString(char *format, double x, double y, double z,
00566  double dx, double dy, double dz){
00567  if(fabs(x)  > 9999999.0 || fabs(y)  > 9999999.0 ||
00568     fabs(z)  > 9999999.0 || fabs(dx) > 9999999.0 ||
00569     fabs(dy) > 9999999.0 || fabs(dz) > 9999999.0)
00570    sprintf(format,"%s","%9.1le");
00571  else if(fabs(x)  > 99999.0 || fabs(y)  > 99999.0 ||
00572          fabs(z)  > 99999.0 || fabs(dx) > 99999.0 ||
00573          fabs(dy) > 99999.0 || fabs(dz) > 99999.0)
00574    sprintf(format,"%s","%9.0lf");
00575  else  sprintf(format,"%s","%9.2lf");
00576 }
00577 
00578 static void GetDoubleCoordinates(int ix, int iy, int iz,
00579                      double *x,  double *y,  double *z,
00580                      double *dx, double *dy, double *dz){
00581  *x = (double)(ix-lrulerx);
00582  *y = (double)(iy-lrulery);
00583  *z = (double)(iz-lrulerz);
00584  *dx = (double)(ix-rulerx);
00585  *dy = (double)(iy-rulery);
00586  *dz = (double)(iz-rulerz);
00587  *x  /= ruler; *y   /=ruler; *z   /=ruler;
00588  *dx /= ruler; *dy /= ruler; *dz /= ruler;
00589 }
00590 
00591 static struct QC {int idBitmap; int dlgID; int idHelp; int iTip;
00592                  HWND hwnd;WNDPROC fpSclass; HBITMAP hbm;} QtCoord[4]={
00593   IDBM_CO1,DLG_COORDS_GOTO,     IDI_COORD_MEASURE, IDI_TIP_C_1,NULL,NULL,NULL,
00594   IDBM_CO2,DLG_COORDS_CANCEL,   IDI_COORD_RELATIVE,IDI_TIP_C_2,NULL,NULL,NULL,
00595   IDBM_CO3,DLG_COORDS_SETCENTRE,IDI_COORD_ORIGIN,  IDI_TIP_C_3,NULL,NULL,NULL,
00596   IDBM_CO4,DLG_COORDS_DEFINE,   IDI_COORD_DEFINE,  IDI_TIP_C_4,NULL,NULL,NULL
00597 };
00598 
00599 static LRESULT CALLBACK CoordinatesSubclassProc(HWND hwnd,UINT msg,
00600                                        WPARAM wParam,LPARAM lParam){
00601  MSG mmsg;
00602  int i,hid;
00603  for(i=0;i<4;i++){
00604    if(QtCoord[i].hwnd == hwnd)goto XXIT;
00605  }
00606  MessageBeep(MB_OK);
00607  XXIT:
00608  mmsg.hwnd=hwnd;
00609  mmsg.message=msg;
00610  mmsg.wParam=wParam;
00611  mmsg.lParam=lParam;
00612  switch (msg) {
00613    case WM_LBUTTONDOWN:
00614    case WM_LBUTTONUP:
00615      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00616                                          0,(LPARAM)(LPMSG)&mmsg);
00617      break;
00618    case WM_MOUSEMOVE:
00619      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00620                                          0,(LPARAM)(LPMSG)&mmsg);
00621      hid=QtCoord[i].idHelp;
00622      if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00623          else SendIconHelpMessage(hid);
00624      break;
00625    default: break;
00626  }
00627  return CallWindowProc(QtCoord[i].fpSclass,hwnd,msg,wParam,lParam);
00628 }
00629 
00630 LRESULT CALLBACK CoordinatesDlgProc(HWND hdlg,UINT msg,
00631                             WPARAM wparam,LPARAM lparam){
00632  BOOL err;
00633  RECT rc;
00634  int i,ix,iy,iz;
00635  double x,y,z,dx,dy,dz;
00636  char string[32],format[10];
00637  static int xpos=-1,ypos=-1,infocus=0,lastid=-1,udflag=1;
00638  switch( msg ) {
00639    case WM_PAINT:
00640      PaintDialogBackground(hdlg,ghinst_main);
00641      break;
00642    case WM_INITDIALOG:
00643      for(i=0;i<4;i++){
00644        QtCoord[i].hbm=LoadBitmap(ghinst_main,
00645                                  MAKEINTRESOURCE(QtCoord[i].idBitmap));
00646        QtCoord[i].hwnd=GetDlgItem(hdlg,QtCoord[i].dlgID);
00647        if(QtCoord[i].hwnd != NULL){
00648          QtCoord[i].fpSclass=(WNDPROC)SetWindowLong(QtCoord[i].hwnd,
00649                               GWL_WNDPROC,(LONG)CoordinatesSubclassProc);
00650          DoAddTooltip(ghwnd_main,QtCoord[i].hwnd,QtCoord[i].iTip);
00651        }
00652      }
00653      if(xpos == -1 && ypos == -1){
00654        xpos=GetPrivateProfileInt(IniSection,"XCOORDPOS",-1,
00655                                  IniFilename);
00656        if(xpos < 0)xpos=52;
00657        ypos=GetPrivateProfileInt(IniSection,"YCOORDPOS",-1,
00658                                  IniFilename);
00659        if(ypos < 0)ypos=50;
00660      }
00661      SetWindowPos(hdlg,HWND_TOP,xpos,ypos,0,0,SWP_NOSIZE);
00662      udflag=1;
00663      PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
00664      return (TRUE);
00665    case WM_CTLCOLORSTATIC:
00666    case WM_CTLCOLORDLG:
00667      SetBkColor((HDC)wparam,RGB(192,192,192));
00668      return (LRESULT)GetStockObject(LTGRAY_BRUSH);
00669    case WM_DRAWITEM:{
00670        BOOL status;
00671        HBITMAP hbm;
00672        LPDRAWITEMSTRUCT lpdis;
00673        lpdis=(LPDRAWITEMSTRUCT)lparam;
00674        if(lpdis->itemState & ODS_SELECTED)status=TRUE; else status=FALSE;
00675        if     (lpdis->CtlID == DLG_COORDS_GOTO)hbm=QtCoord[0].hbm;
00676        else if(lpdis->CtlID == DLG_COORDS_CANCEL)hbm=QtCoord[1].hbm;
00677        else if(lpdis->CtlID == DLG_COORDS_SETCENTRE)hbm=QtCoord[2].hbm;
00678        else if(lpdis->CtlID == DLG_COORDS_DEFINE)hbm=QtCoord[3].hbm;
00679        DrawQtBtn(status,lpdis->hDC,&(lpdis->rcItem),hbm);
00680      }
00681      return TRUE;
00682    case WM_DESTROY:
00683      for(i=0;i<4;i++){
00684        if(QtCoord[i].hbm != NULL)DeleteObject(QtCoord[i].hbm);
00685        if(QtCoord[i].fpSclass != NULL)SetWindowLong(QtCoord[i].hwnd,
00686          GWL_WNDPROC,(LONG)QtCoord[i].fpSclass);
00687      }
00688      GetWindowRect(hdlg,&rc);
00689      xpos=rc.left; ypos=rc.top;
00690      sprintf(string,"%ld",xpos);
00691      WritePrivateProfileString(IniSection,"XCOORDPOS",string,IniFilename);
00692      sprintf(string,"%ld",ypos);
00693      WritePrivateProfileString(IniSection,"YCOORDPOS",string,IniFilename);
00694      break;
00695    case WM_NCHITTEST:
00696      if(current_message >= 0){
00697        current_message = -1;
00698        SendPrgmMessage(IDS_ZERO,1);
00699      }
00700      break;
00701    case WM_COMMAND:
00702      switch(HIWORD(wparam)){
00703        case EN_SETFOCUS:
00704          infocus=1;
00705          break;
00706        case EN_KILLFOCUS:
00707          infocus=0;
00708          break;
00709        case EN_CHANGE:
00710          if(!infocus)break;
00711          udflag=1;
00712          i=(int)LOWORD(wparam);
00713          if(GetDlgItemText(hdlg,i,string,30) != 0){
00714            if(i == DLG_COORDS_X){
00715              if(lastid == DLG_COORDS_DX)break;
00716              ix=(int)(atof(string)*ruler)+lrulerx;
00717              GetDoubleCoordinates(ix,NpointerY,NpointerZ,
00718                               &x,&y,&z,&dx,&dy,&dz);
00719              GetFormatString(format,x,y,z,dx,dy,dz);
00720              sprintf(string,format,dx);
00721              lastid=i;
00722              SetDlgItemText(hdlg,DLG_COORDS_DX,string);
00723              lastid=-1;
00724            }
00725            else if(i == DLG_COORDS_Y){
00726              if(lastid == DLG_COORDS_DY)break;
00727              iy=(int)(atof(string)*ruler)+lrulery;
00728              GetDoubleCoordinates(NpointerX,iy,NpointerZ,
00729                               &x,&y,&z,&dx,&dy,&dz);
00730              GetFormatString(format,x,y,z,dx,dy,dz);
00731              sprintf(string,format,dy);
00732              lastid=i;
00733              SetDlgItemText(hdlg,DLG_COORDS_DY,string);
00734              lastid= -1;
00735            }
00736            else if(i == DLG_COORDS_Z){
00737              if(lastid == DLG_COORDS_DZ)break;
00738              iz=(int)(atof(string)*ruler)+lrulerz;
00739              GetDoubleCoordinates(NpointerX,NpointerY,iz,
00740                               &x,&y,&z,&dx,&dy,&dz);
00741              GetFormatString(format,x,y,z,dx,dy,dz);
00742              sprintf(string,format,dz);
00743              lastid=i;
00744              SetDlgItemText(hdlg,DLG_COORDS_DZ,string);
00745              lastid= -1;
00746            }
00747            else if(i == DLG_COORDS_DX){
00748              if(lastid == DLG_COORDS_X)break;
00749              ix=(int)(atof(string)*ruler)+rulerx;
00750              GetDoubleCoordinates(ix,NpointerY,NpointerZ,
00751                               &x,&y,&z,&dx,&dy,&dz);
00752              GetFormatString(format,x,y,z,dx,dy,dz);
00753              sprintf(string,format,x);
00754              lastid=i;
00755              SetDlgItemText(hdlg,DLG_COORDS_X,string);
00756              lastid= -1;
00757            }
00758            else if(i == DLG_COORDS_DY){
00759              if(lastid == DLG_COORDS_Y)break;
00760              iy=(int)(atof(string)*ruler)+rulery;
00761              GetDoubleCoordinates(NpointerX,iy,NpointerZ,
00762                               &x,&y,&z,&dx,&dy,&dz);
00763              GetFormatString(format,x,y,z,dx,dy,dz);
00764              sprintf(string,format,y);
00765              lastid=i;
00766              SetDlgItemText(hdlg,DLG_COORDS_Y,string);
00767              lastid= -1;
00768            }
00769            else if(i == DLG_COORDS_DZ){
00770              if(lastid == DLG_COORDS_Z)break;
00771              iz=(int)(atof(string)*ruler)+rulerz;
00772              GetDoubleCoordinates(NpointerX,NpointerY,iz,
00773                               &x,&y,&z,&dx,&dy,&dz);
00774              GetFormatString(format,x,y,z,dx,dy,dz);
00775              sprintf(string,format,z);
00776              lastid=i;
00777              SetDlgItemText(hdlg,DLG_COORDS_Z,string);
00778              lastid= -1;
00779            }
00780          }
00781          break;
00782        default:   break;
00783      }
00784      switch(LOWORD(wparam)){
00785        case IDCANCEL:
00786          PostMessage(ghwnd_main,WM_COMMAND,IDM_WINDOW_COORDS,0);
00787          break;
00788        case IDOK:
00789        case DLG_COORDS_GOTO:{
00790            point p;
00791            if(GetDlgItemText(hdlg,DLG_COORDS_X,string,30) == 0)break;
00792            p[0]=(long)(atof(string)*ruler)+lrulerx;
00793            if(GetDlgItemText(hdlg,DLG_COORDS_Y,string,30) == 0)break;
00794            p[1]=(long)(atof(string)*ruler)+lrulery;
00795            if(GetDlgItemText(hdlg,DLG_COORDS_Z,string,30) == 0)break;
00796            p[2]=(long)(atof(string)*ruler)+lrulerz;
00797            if( (p[0] > TVpointX && p[0] < TVpointX+TVsizeX)
00798             && (p[1] > TVpointY && p[1] < TVpointY+TVsizeY)
00799             && (p[2] > TVpointZ && p[2] < TVpointZ+TVsizeZ)){ /* move 3D cursor */
00800              Draw3dCursor();
00801              NpointerX=p[0];  NpointerY=p[1];  NpointerZ=p[2];
00802              Draw3dCursor();
00803            }
00804            else{
00805              NpointerX=p[0];  NpointerY=p[1];  NpointerZ=p[2];
00806              TVpointX=NpointerX-TVsizeX/2;  TVcentreX=NpointerX;
00807              TVpointY=NpointerY-TVsizeY/2;  TVcentreY=NpointerY;
00808              TVpointZ=NpointerZ-TVsizeZ/2;  TVcentreZ=NpointerZ;
00809              DrawModel();
00810            }
00811            PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
00812          }
00813          break;
00814        case DLG_COORDS_CANCEL:
00815          if(HIWORD(wparam) != BN_CLICKED)break;
00816          udflag=1;
00817          PostMessage(hdlg,WM_COMMAND,IDC_COORD_UPDATE,0);
00818          break;
00819        case DLG_COORDS_SETCENTRE:
00820          if(HIWORD(wparam) != BN_CLICKED)break;
00821          SendMessage(ghwnd_main,WM_COMMAND,IDM_COORDS_ORIGIN,0);
00822          break;
00823        case DLG_COORDS_DEFINE:
00824          if(HIWORD(wparam) != BN_CLICKED)break;
00825          SendMessage(ghwnd_main,WM_COMMAND,IDM_COORDS_DEFINE,0);
00826          break;
00827        case IDC_COORD_UPDATE:
00828          GetDoubleCoordinates(NpointerX,NpointerY,NpointerZ,
00829                               &x,&y,&z,&dx,&dy,&dz);
00830          GetFormatString(format,x,y,z,dx,dy,dz);
00831          sprintf(string,format,x);  SetDlgItemText(hdlg,DLG_COORDS_X,string);
00832          sprintf(string,format,y);  SetDlgItemText(hdlg,DLG_COORDS_Y,string);
00833          sprintf(string,format,z);  SetDlgItemText(hdlg,DLG_COORDS_Z,string);
00834          rulerx=NpointerX; rulery=NpointerY; rulerz=NpointerZ;
00835          if(udflag){
00836            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DX,string);
00837            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DY,string);
00838            sprintf(string,format,0.0);SetDlgItemText(hdlg,DLG_COORDS_DZ,string);
00839            udflag=0;
00840          }
00841          break;
00842        default:   break;
00843      }
00844      break;
00845    default: break;
00846  }
00847  return(FALSE);
00848 }
00849 
00850 static struct QL {int idBitmap; int dlgID; int idHelp; int iTip;
00851                  HWND hwnd;WNDPROC fpSclass; HBITMAP hbm;} QtLock[5]={
00852   IDBM_LOCK1,DLG_LOCK_SQ, IDI_LOCK_SNAP1,  IDI_TIP_M_1,NULL,NULL,NULL,
00853   IDBM_LOCK2,DLG_LOCK_CI, IDI_LOCK_SNAP2,  IDI_TIP_M_2,NULL,NULL,NULL,
00854   IDBM_LOCK3,DLG_LOCK_TR, IDI_LOCK_SNAP3,  IDI_TIP_M_3,NULL,NULL,NULL,
00855   IDBM_LOCK4,DLG_LOCK_LK, IDI_LOCK_LOCK,   IDI_TIP_M_4,NULL,NULL,NULL,
00856   IDBM_LOCK5,DLG_LOCK_XX, NO_HELP,         IDI_TIP_M_5,NULL,NULL,NULL
00857 };
00858 
00859 static LRESULT CALLBACK LockSubclassProc(HWND hwnd,UINT msg,
00860                                          WPARAM wParam,LPARAM lParam){
00861  MSG mmsg;
00862  int i,hid;
00863  for(i=0;i<5;i++){
00864    if(QtLock[i].hwnd == hwnd)goto XXIT;
00865  }
00866  MessageBeep(MB_OK);
00867  XXIT:
00868  mmsg.hwnd=hwnd;
00869  mmsg.message=msg;
00870  mmsg.wParam=wParam;
00871  mmsg.lParam=lParam;
00872  switch (msg) {
00873    case WM_LBUTTONDOWN:
00874    case WM_LBUTTONUP:
00875      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00876                                          0,(LPARAM)(LPMSG)&mmsg);
00877      break;
00878    case WM_MOUSEMOVE:
00879      if(ghwndTooltip != NULL)SendMessage(ghwndTooltip,TTM_RELAYEVENT,
00880                                          0,(LPARAM)(LPMSG)&mmsg);
00881      hid=QtLock[i].idHelp;
00882      if(hid == NO_HELP)SendPrgmMessage(IDS_ZERO,1);
00883          else SendIconHelpMessage(hid);
00884      break;
00885    default: break;
00886  }
00887  return CallWindowProc(QtLock[i].fpSclass,hwnd,msg,wParam,lParam);
00888 }
00889 
00890 LRESULT CALLBACK LockDlgProc(HWND hdlg,UINT msg,
00891                              WPARAM wparam,LPARAM lparam){
00892  RECT rc;
00893  int i;
00894  static int xpos=-1,ypos=-1;
00895  switch( msg ) {
00896    case WM_PAINT:
00897      PaintDialogBackground(hdlg,ghinst_main);
00898      break;
00899    case WM_INITDIALOG:
00900      for(i=0;i<5;i++){
00901        QtLock[i].hbm=LoadBitmap(ghinst_main,
00902                                 MAKEINTRESOURCE(QtLock[i].idBitmap));
00903        QtLock[i].hwnd=GetDlgItem(hdlg,QtLock[i].dlgID);
00904        if(QtLock[i].hwnd != NULL){
00905          QtLock[i].fpSclass=(WNDPROC)SetWindowLong(QtLock[i].hwnd,
00906                               GWL_WNDPROC,(LONG)LockSubclassProc);
00907          DoAddTooltip(ghwnd_main,QtLock[i].hwnd,QtLock[i].iTip);
00908        }
00909      }
00910      if(xpos == -1 && ypos == -1){
00911        GetWindowRect(ghwndTools,&rc);
00912        xpos=52; ypos=200;
00913      }
00914      SetWindowPos(hdlg,HWND_TOP,xpos,ypos,0,0,SWP_NOSIZE);
00915      return (TRUE);
00916    case WM_CTLCOLORSTATIC:
00917    case WM_CTLCOLORDLG:
00918      SetBkColor((HDC)wparam,RGB(192,192,192));
00919      return (LRESULT)GetStockObject(LTGRAY_BRUSH);
00920    case WM_DRAWITEM:{
00921        BOOL status;
00922        HBITMAP hbm;
00923        LPDRAWITEMSTRUCT lpdis;
00924        lpdis=(LPDRAWITEMSTRUCT)lparam;
00925        if(lpdis->itemState & ODS_SELECTED)status=TRUE; else status=FALSE;
00926        if     (lpdis->CtlID == DLG_LOCK_SQ)hbm=QtLock[0].hbm;
00927        else if(lpdis->CtlID == DLG_LOCK_CI)hbm=QtLock[1].hbm;
00928        else if(lpdis->CtlID == DLG_LOCK_TR)hbm=QtLock[2].hbm;
00929        else if(lpdis->CtlID == DLG_LOCK_LK){
00930          if(SelectedBrush >= 0)hbm=QtLock[3].hbm;
00931          else hbm=NULL;
00932        }
00933        else if(lpdis->CtlID == DLG_LOCK_XX)hbm=QtLock[4].hbm;
00934        DrawQtBtn(status,lpdis->hDC,&(lpdis->rcItem),hbm);
00935      }
00936      return TRUE;
00937    case WM_DESTROY:
00938      for(i=0;i<5;i++){
00939        if(QtLock[i].hbm != NULL)DeleteObject(QtLock[i].hbm);
00940        if(QtLock[i].fpSclass != NULL)SetWindowLong(QtLock[i].hwnd,
00941          GWL_WNDPROC,(LONG)QtLock[i].fpSclass);
00942      }
00943      GetWindowRect(hdlg,&rc);
00944      xpos=rc.left; ypos=rc.top;
00945      break;
00946    case WM_COMMAND:
00947      switch(LOWORD(wparam)){
00948        case IDCANCEL:
00949        case IDOK:
00950          PostMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
00951          break;
00952        case DLG_LOCK_SQ:
00953          if(HIWORD(wparam) != BN_CLICKED)break;
00954          PostMessage(ghwnd_main,WM_COMMAND,IDM_LOCK_SQUARE,0);
00955          break;
00956        case DLG_LOCK_CI:
00957          if(HIWORD(wparam) != BN_CLICKED)break;
00958          PostMessage(ghwnd_main,WM_COMMAND,IDM_LOCK_CIRCLE,0);
00959          break;
00960        case DLG_LOCK_TR:
00961          if(HIWORD(wparam) != BN_CLICKED)break;
00962          PostMessage(ghwnd_main,WM_COMMAND,IDM_LOCK_TRIANGLE,0);
00963          break;
00964        case DLG_LOCK_LK:
00965          if(HIWORD(wparam) != BN_CLICKED)break;
00966          PostMessage(ghwnd_main,WM_COMMAND,IDM_LOCK_LOCK,0);
00967          break;
00968        case DLG_LOCK_XX:
00969          if(HIWORD(wparam) != BN_CLICKED)break;
00970          PostMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
00971          break;
00972        default:   break;
00973      }
00974      break;
00975    default: break;
00976  }
00977  return(FALSE);
00978 }
00979 
00980 static void DoAddTooltip(HWND hwndOwner, HWND tipon, int resid){
00981  TOOLINFO ti;
00982  if(ghwndTooltip == NULL || tipon == NULL)return;
00983  memset(&ti,0,sizeof(TOOLINFO));
00984  ti.cbSize = sizeof(TOOLINFO);
00985  ti.uFlags = TTF_IDISHWND;
00986  ti.hwnd = hwndOwner;
00987  ti.hinst = ghinst_main;
00988  ti.uId = (UINT)tipon;
00989  ti.lpszText = (LPSTR)resid;
00990  SendMessage(ghwndTooltip,TTM_ADDTOOL,0,(LPARAM) (LPTOOLINFO) &ti);
00991  return;
00992 }
00993 
00994 static HWND DoCreateTooltip(HWND hwndOwner){
00995  HWND hwndTT;
00996  hwndTT = CreateWindow(TOOLTIPS_CLASS, (LPSTR) NULL, TTS_ALWAYSTIP,
00997      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
00998      hwndOwner, (HMENU) NULL, ghinst_main, NULL);
00999  return hwndTT;
01000 }

Generated on Sun Apr 27 14:20:09 2014 for OpenFX by  doxygen 1.5.6