Cliphance copy paste enhancement
When I started developement of Cliphance, I decided to implement the "stay where I put you window management strategy"(StayWIPY). All window positions and sizes could be saved for future use. My pet peeve in Windows is opening a new window and moving and sizing that window in the same manner over and over again. Aren't computers supposed to save repetitive work. Shouldn't windows implement some kind of strategy to prevent that repitive work. Well, I believe so!
Implementing StayWIPY for the window size and position was straightforward and not at all difficult. However, implementing StayWIPY for the running icon position was problematic. After several failed attempts, I had abandoned the StayWIPY strategy for icons. However, after developing clipviewer windows and icons and paste selection capabilites on the windows, the demand for smarter icons grew.
With no other StayWIPY icon applications to spy on, I was forced to spy in trial and error and error and error. After many hours of customizing Windows frustration, I conquered the message maze with a StayWIPY implementation for running icons.
You may freely use the code at your own risk.
The code was compiled under Symantec 7.21, the complete project is a self extracting executable, instpos.exe. Feel free to reproduce in any form whatsoever.
#define UNDOCUMENTED_SYS_COMMAND 0xF012 #define WM_SYS_UNDOCUMENTED_COMPLETE WM_USER + 1extern int iIconXPos ;//Saved icon position. extern int iIconYPos ;//Saved icon position. extern int iIconWidth ;//System icon size. extern int iIconHeight ;//System icon size.
//Could be static in WndProc: bSetIconPos = TRUE ;//Control icon position? Set from icon position values. bIsIconSetting = FALSE ;//Setting the icon position? bIsInSYSUndocumented = FALSE ;//Undocumented system command message?
long CALLBACK _export WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_MOVE : if (IsIconic(hwnd)) { //Message is sent on icon drag or on MoveWindow(). if (!bSetIconPos) { //Not in control of icon position. break ; } if (bIsIconSetting) { //The icon is being positioned on MoveWindow() below. break ; } //The icon has been dragged therefor stop maintaining the icon position. bSetIconPos = FALSE ; } break ;
case WM_WINDOWPOSCHANGED : if (IsIconic(hwnd)) { //The icon is to be moved. if (!bSetIconPos) { //Not in control of icon position. break ; } if (bIsInSYSUndocumented) { //Do not MoveWindow() for undocumented system command. break ;// but allow default processing. } if (bIsIconSetting) { //The icon is being positioned on MoveWindow() below. return 0 ;//do not allow default processing. } bIsIconSetting = TRUE ; MoveWindow(hwnd, iIconXPos, iIconYPos, iIconWidth, iIconHeight, FALSE) ; //The icon position has been set. bIsIconSetting = FALSE ; return 0 ; //do not allow default processing. } break ;
case WM_SYSCOMMAND: if (wParam == UNDOCUMENTED_SYS_COMMAND) { //This message is sent when icon gains focus, followed by //WM_WINDOWPOSCHANGED which must be ignored. if (!bSetIconPos) { //Not in control of icon position. break ; } bIsInSYSUndocumented = TRUE ; //Post message so that bIsInSYSUndocumented can be reset below. PostMessage(hwnd, WM_SYS_UNDOCUMENTED_COMPLETE, (WPARAM) hwnd, 0L) ; } break ;
case WM_SYS_UNDOCUMENTED_COMPLETE : //Posted message that undocumented system command processing is complete. bIsInSYSUndocumented = FALSE ; break ;
//Other message processing.
} return DefWindowProc(hwnd, message, wParam, lParam) ; }
E-Mail Address on Internet: quill@codenquill.win.net