Changeset 337 for trunk/src/helpers/winh.c
- Timestamp:
- Oct 31, 2006, 3:11:11 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/winh.c
r336 r337 2648 2648 2649 2649 /* 2650 *@@ winhStoreWindowPos: 2651 * saves the position of a certain window in the same format 2652 * as the barely documented WinStoreWindowPos API. 2653 * This uses the completely undocumented calls 2654 * WinGetFrameTreePPSize and WinGetFrameTreePPs imported 2655 * from PMWIN.DLL ordinals 972 and 973. 2656 * 2657 * The window should still be visible on the screen 2658 * when calling this function. Do not call it in WM_DESTROY, 2659 * because then the SWP data is no longer valid. 2660 * 2661 * This returns TRUE if saving was successful. 2662 * 2663 *@@added XWP V1.0.6 (2006-10-31) [pr]: @@fixes 458 2664 */ 2665 2666 BOOL winhStoreWindowPos(HWND hwnd, // in: window to save 2667 HINI hIni, // in: INI file (or HINI_USER/SYSTEM) 2668 const char *pcszApp, // in: INI application name 2669 const char *pcszKey) // in: INI key name 2670 { 2671 BOOL brc = FALSE; 2672 SWP swp; 2673 2674 if (WinQueryWindowPos(hwnd, &swp)) 2675 { 2676 ULONG ulSizePP = WinGetFrameTreePPSize(hwnd); 2677 ULONG ulSize = sizeof(STOREPOS) + ulSizePP; 2678 PSTOREPOS pStorePos; 2679 2680 if ((pStorePos = malloc(ulSize))) 2681 { 2682 // This first bit is all guesswork as I don't know what it all means, 2683 // but it always seems to be the same everywhere I've looked. 2684 pStorePos->usMagic = 0x7B6A; 2685 pStorePos->ulRes1 = 1; 2686 pStorePos->ulRes2 = 1; 2687 pStorePos->ulRes3 = 0x0400; 2688 pStorePos->ulRes4 = 0x0300; 2689 pStorePos->ulRes5 = 0xFFFFFFFF; 2690 pStorePos->ulRes6 = 0xFFFFFFFF; 2691 2692 pStorePos->ulFlags = swp.fl; 2693 pStorePos->usXPos = pStorePos->usRestoreXPos = swp.x; 2694 pStorePos->usYPos = pStorePos->usRestoreYPos = swp.y; 2695 pStorePos->usWidth = pStorePos->usRestoreWidth = swp.cx; 2696 pStorePos->usHeight = pStorePos->usRestoreHeight = swp.cy; 2697 if (swp.fl & (SWP_MAXIMIZE | SWP_MINIMIZE)) 2698 { 2699 pStorePos->usRestoreXPos = WinQueryWindowUShort(hwnd, QWS_XRESTORE); 2700 pStorePos->usRestoreYPos = WinQueryWindowUShort(hwnd, QWS_YRESTORE); 2701 pStorePos->usRestoreWidth = WinQueryWindowUShort(hwnd, QWS_CXRESTORE); 2702 pStorePos->usRestoreHeight = WinQueryWindowUShort(hwnd, QWS_CYRESTORE); 2703 } 2704 2705 pStorePos->usMinXPos = WinQueryWindowUShort(hwnd, QWS_XMINIMIZE); 2706 pStorePos->usMinYPos = WinQueryWindowUShort(hwnd, QWS_YMINIMIZE); 2707 pStorePos->ulPPLen = WinGetFrameTreePPs(hwnd, ulSizePP, pStorePos + 1); 2708 ulSize = pStorePos->ulPPLen + sizeof(STOREPOS); 2709 brc = PrfWriteProfileData(hIni, (PSZ)pcszApp, (PSZ)pcszKey, pStorePos, ulSize); 2710 free(pStorePos); 2711 } 2712 } 2713 return brc; 2714 } 2715 2716 /* 2650 2717 *@@ winhAdjustControls: 2651 2718 * helper function for dynamically adjusting a window's
Note:
See TracChangeset
for help on using the changeset viewer.