Changeset 61
- Timestamp:
- Apr 19, 2001, 11:15:17 PM (24 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/helpers/dialog.h
r54 r61 9 9 *@@added V0.9.9 (2001-04-01) [umoeller] 10 10 *@@include <os2.h> 11 *@@include #include "dialog.h" 11 *@@include #include "helpers\linklist.h" // for mnemonic helpers 12 *@@include #include "helpers\dialog.h" 12 13 */ 13 14 … … 185 186 const char *pcszControlsFont); 186 187 188 VOID dlghSetPrevFocus(PVOID pvllWindows); 189 190 VOID dlghSetNextFocus(PVOID pvllWindows); 191 192 HWND dlghProcessMnemonic(PVOID pvllWindows, 193 USHORT usch); 194 195 BOOL dlghEnter(PVOID pvllWindows); 196 187 197 #endif 188 198 -
trunk/src/helpers/dialog.c
r55 r61 42 42 #define INCL_WINFRAMEMGR 43 43 #define INCL_WINDIALOGS 44 #define INCL_WININPUT 44 45 #define INCL_WINBUTTONS 45 46 #define INCL_WINSTATICS … … 1456 1457 } 1457 1458 1458 1459 /* 1460 *@@ dlghSetPrevFocus: 1461 * "backward" function for rotating the focus 1462 * in a dialog when the "shift+tab" keys get 1463 * pressed. 1464 * 1465 * pllWindows must be a linked list with the 1466 * plain HWND window handles of the focussable 1467 * controls in the dialog. 1468 */ 1469 1470 VOID dlghSetPrevFocus(PVOID pvllWindows) 1471 { 1472 PLINKLIST pllWindows = (PLINKLIST)pvllWindows; 1473 1474 // check current focus 1475 HWND hwndFocus = WinQueryFocus(HWND_DESKTOP); 1476 1477 PLISTNODE pNode = lstNodeFromItem(pllWindows, (PVOID)hwndFocus); 1478 1479 BOOL fRestart = FALSE; 1480 1481 while (pNode) 1482 { 1483 CHAR szClass[100]; 1484 1485 // previos node 1486 pNode = pNode->pPrevious; 1487 1488 if ( (!pNode) // no next, or not found: 1489 && (!fRestart) // avoid infinite looping if bad list 1490 ) 1491 { 1492 pNode = lstQueryLastNode(pllWindows); 1493 fRestart = TRUE; 1494 } 1495 1496 if (pNode) 1497 { 1498 // check if this is a focusable control 1499 if (WinQueryClassName((HWND)pNode->pItemData, 1500 sizeof(szClass), 1501 szClass)) 1502 { 1503 if ( (strcmp(szClass, "#5")) // not static 1504 ) 1505 break; 1506 // else: go for next then 1507 } 1508 } 1509 } 1510 1511 if (pNode) 1512 { 1513 WinSetFocus(HWND_DESKTOP, 1514 (HWND)pNode->pItemData); 1515 } 1516 } 1517 1518 /* 1519 *@@ dlghSetNextFocus: 1520 * "forward" function for rotating the focus 1521 * in a dialog when the "ab" key gets pressed. 1522 * 1523 * pllWindows must be a linked list with the 1524 * plain HWND window handles of the focussable 1525 * controls in the dialog. 1526 */ 1527 1528 VOID dlghSetNextFocus(PVOID pvllWindows) 1529 { 1530 PLINKLIST pllWindows = (PLINKLIST)pvllWindows; 1531 1532 // check current focus 1533 HWND hwndFocus = WinQueryFocus(HWND_DESKTOP); 1534 1535 PLISTNODE pNode = lstNodeFromItem(pllWindows, (PVOID)hwndFocus); 1536 1537 BOOL fRestart = FALSE; 1538 1539 while (pNode) 1540 { 1541 CHAR szClass[100]; 1542 1543 // next focus in node 1544 pNode = pNode->pNext; 1545 1546 if ( (!pNode) // no next, or not found: 1547 && (!fRestart) // avoid infinite looping if bad list 1548 ) 1549 { 1550 pNode = lstQueryFirstNode(pllWindows); 1551 fRestart = TRUE; 1552 } 1553 1554 if (pNode) 1555 { 1556 // check if this is a focusable control 1557 if (WinQueryClassName((HWND)pNode->pItemData, 1558 sizeof(szClass), 1559 szClass)) 1560 { 1561 if ( (strcmp(szClass, "#5")) // not static 1562 ) 1563 break; 1564 // else: go for next then 1565 } 1566 } 1567 } 1568 1569 if (pNode) 1570 { 1571 WinSetFocus(HWND_DESKTOP, 1572 (HWND)pNode->pItemData); 1573 } 1574 } 1575 1576 /* 1577 *@@ MatchMnemonic: 1578 * returns TRUE if the specified control matches 1579 * 1580 * 1581 *@@added V0.9.9 (2001-03-17) [umoeller] 1582 */ 1583 1584 /* 1585 *@@ dlghProcessMnemonic: 1586 * finds the control which matches usch 1587 * and gives it the focus. If this is a 1588 * static control, the next control in the 1589 * list is given focus instead. (Standard 1590 * dialog behavior.) 1591 * 1592 * Pass in usch from WM_CHAR. It is assumed 1593 * that the caller has already tested for 1594 * the "alt" key to be depressed. 1595 * 1596 *@@added V0.9.9 (2001-03-17) [umoeller] 1597 */ 1598 1599 HWND dlghProcessMnemonic(PVOID pvllWindows, 1600 USHORT usch) 1601 { 1602 PLINKLIST pllWindows = (PLINKLIST)pvllWindows; 1603 1604 HWND hwndFound = NULLHANDLE; 1605 PLISTNODE pNode = lstQueryFirstNode(pllWindows); 1606 CHAR szClass[100]; 1607 1608 while (pNode) 1609 { 1610 HWND hwnd = (HWND)pNode->pItemData; 1611 1612 if (WinSendMsg(hwnd, 1613 WM_MATCHMNEMONIC, 1614 (MPARAM)usch, 1615 0)) 1616 { 1617 // according to the docs, only buttons and static 1618 // return TRUE to that msg; 1619 // if this is a static, give focus to the next 1620 // control 1621 1622 _Pmpf((__FUNCTION__ ": hwnd 0x%lX", hwnd)); 1623 1624 // check if this is a focusable control 1625 if (WinQueryClassName(hwnd, 1626 sizeof(szClass), 1627 szClass)) 1628 { 1629 if (!strcmp(szClass, "#3")) 1630 // it's a button: click it 1631 WinSendMsg(hwnd, BM_CLICK, (MPARAM)TRUE, 0); 1632 else if (!strcmp(szClass, "#5")) 1633 { 1634 // it's a static: give focus to following control 1635 pNode = pNode->pNext; 1636 if (pNode) 1637 WinSetFocus(HWND_DESKTOP, (HWND)pNode->pItemData); 1638 } 1639 } 1640 else 1641 // any other control (are there any?): give them focus 1642 WinSetFocus(HWND_DESKTOP, hwnd); 1643 1644 // in any case, stop 1645 hwndFound = hwnd; 1646 break; 1647 } 1648 1649 pNode = pNode->pNext; 1650 } 1651 1652 return (hwndFound); 1653 } 1654 1655 /* 1656 *@@ dlghEnter: 1657 * presses the first button with BS_DEFAULT. 1658 */ 1659 1660 BOOL dlghEnter(PVOID pvllWindows) 1661 { 1662 PLINKLIST pllWindows = (PLINKLIST)pvllWindows; 1663 1664 PLISTNODE pNode = lstQueryFirstNode(pllWindows); 1665 CHAR szClass[100]; 1666 while (pNode) 1667 { 1668 HWND hwnd = (HWND)pNode->pItemData; 1669 if (WinQueryClassName(hwnd, 1670 sizeof(szClass), 1671 szClass)) 1672 { 1673 if (!strcmp(szClass, "#3")) // button 1674 { 1675 _Pmpf((__FUNCTION__ ": found button")); 1676 if ( (WinQueryWindowULong(hwnd, QWL_STYLE) & (BS_PUSHBUTTON | BS_DEFAULT)) 1677 == (BS_PUSHBUTTON | BS_DEFAULT) 1678 ) 1679 { 1680 _Pmpf((" is default!")); 1681 WinPostMsg(hwnd, 1682 BM_CLICK, 1683 (MPARAM)TRUE, // upclick 1684 0); 1685 return (TRUE); 1686 } 1687 } 1688 } 1689 1690 pNode = pNode->pNext; 1691 } 1692 1693 return (FALSE); 1694 } 1695 1696
Note:
See TracChangeset
for help on using the changeset viewer.