Annotation of pmsdk/samples/linefrac/lfutil.c, revision 1.1.1.1

1.1       root        1: /************************************************************************
                      2: *
                      3: *   lfutil.c -- Utility subroutines.
                      4: *
                      5: *   Created by Microsoft Corporation, 1989
                      6: *
                      7: ************************************************************************/
                      8: 
                      9: #define INCL_WIN
                     10: #define INCL_GPI
                     11: #include <os2.h>
                     12: 
                     13: #include <mt\stdio.h>
                     14: #include <mt\stdlib.h>
                     15: #include "linefrac.h"
                     16: 
                     17: #define INCL_LFUTIL
                     18: #include "lffuncs.h"
                     19: 
                     20: 
                     21: 
                     22: 
                     23: /************************************************************************
                     24: *
                     25: *   MySetWindowUShort
                     26: *
                     27: *   Sets the given control id to the value specified.
                     28: *
                     29: ************************************************************************/
                     30: 
                     31: VOID
                     32: MySetWindowUShort(hWnd, id, num)
                     33: HWND hWnd;
                     34: USHORT id;
                     35: USHORT num;
                     36: {
                     37:     char szStr[CCHSTR];
                     38: 
                     39:     sprintf((NPCH)szStr, "%u", num);
                     40:     WinSetWindowText(WinWindowFromID(hWnd, id), (PCH)szStr);
                     41: }
                     42: 
                     43: 
                     44: 
                     45: 
                     46: /************************************************************************
                     47: *
                     48: *   MySetWindowLong
                     49: *
                     50: *   Sets the given control id to the value specified.
                     51: *
                     52: ************************************************************************/
                     53: 
                     54: VOID
                     55: MySetWindowLong(hWnd, id, num)
                     56: HWND hWnd;
                     57: USHORT id;
                     58: LONG num;
                     59: {
                     60:     char szStr[CCHSTR];
                     61: 
                     62:     sprintf((NPCH)szStr, "%ld", num);
                     63:     WinSetWindowText(WinWindowFromID(hWnd, id), (PCH)szStr);
                     64: }
                     65: 
                     66: 
                     67: 
                     68: 
                     69: /************************************************************************
                     70: *
                     71: *   MySetWindowDouble
                     72: *
                     73: *   Sets the given control id to the value specified.
                     74: *
                     75: ************************************************************************/
                     76: 
                     77: VOID
                     78: MySetWindowDouble(hWnd, id, num)
                     79: HWND hWnd;
                     80: USHORT id;
                     81: double num;
                     82: {
                     83:     char szStr[CCHSTR];
                     84: 
                     85:     sprintf((NPCH)szStr, "%lf", num);
                     86:     WinSetWindowText(WinWindowFromID(hWnd, id), (PCH)szStr);
                     87: }
                     88: 
                     89: 
                     90: 
                     91: 
                     92: /************************************************************************
                     93: *
                     94: *   MyGetWindowUShort
                     95: *
                     96: *   Returns the value from the given control id.
                     97: *
                     98: ************************************************************************/
                     99: 
                    100: VOID
                    101: MyGetWindowUShort(hWnd, id, pus)
                    102: HWND hWnd;
                    103: USHORT id;
                    104: PUSHORT pus;
                    105: {
                    106:     char szStr[CCHSTR];
                    107: 
                    108:     WinQueryWindowText(WinWindowFromID(hWnd, id), CCHSTR, (PCH)szStr);
                    109:     *pus = atoi(szStr);
                    110: }
                    111: 
                    112: 
                    113: 
                    114: 
                    115: /************************************************************************
                    116: *
                    117: *   MyGetWindowLong
                    118: *
                    119: *   Returns the value from the given control id.
                    120: *
                    121: ************************************************************************/
                    122: 
                    123: VOID
                    124: MyGetWindowLong(hWnd, id, pl)
                    125: HWND hWnd;
                    126: USHORT id;
                    127: PLONG  pl;
                    128: {
                    129:     char szStr[CCHSTR];
                    130: 
                    131:     WinQueryWindowText(WinWindowFromID(hWnd, id), CCHSTR, (PCH)szStr);
                    132:     *pl = atol(szStr);
                    133: }
                    134: 
                    135: 
                    136: 
                    137: 
                    138: /************************************************************************
                    139: *
                    140: *   MyGetWindowDouble
                    141: *
                    142: *   Returns the value from the given control id.
                    143: *
                    144: ************************************************************************/
                    145: 
                    146: VOID
                    147: MyGetWindowDouble(hWnd, id, pdbl)
                    148: HWND   hWnd;
                    149: USHORT id;
                    150: PDBL   pdbl;
                    151: {
                    152:     char szStr[CCHSTR];
                    153: 
                    154:     WinQueryWindowText(WinWindowFromID(hWnd, id), CCHSTR, (PCH)szStr);
                    155:     *pdbl = atof(szStr);
                    156: }
                    157: 
                    158: 
                    159: 
                    160: 
                    161: /************************************************************************
                    162: *
                    163: *   MyMessageBox
                    164: *
                    165: *   Displays a message box with the given string.  To simplify matters,
                    166: *   the box will always have the same title ("LineFractal"), will always
                    167: *   have a single button ("Ok"), will always have an exclamation point
                    168: *   icon, and will always be application modal.
                    169: *
                    170: ************************************************************************/
                    171: 
                    172: VOID
                    173: MyMessageBox(hWnd, sz)
                    174: HWND hWnd;
                    175: PSZ sz;
                    176: {
                    177:     static char *szTitle = "LineFractal";
                    178: 
                    179:     WinMessageBox(HWND_DESKTOP, hWnd, sz, szTitle, NULL,
                    180:                  MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
                    181: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.