delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/10/27/16:42:34

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <89B0CF7B746AD211954A0008C75D90E303B377C4@gzs-mail-2.gzs.de>
From: =?iso-8859-1?Q?=22Quo=DF=2C_Clemens=22?= <clemens DOT quoss AT gzs DOT de>
To: "'cygwin AT sources DOT redhat DOT com'" <cygwin AT sources DOT redhat DOT com>
Subject: RE: newbie question: hellowin on Windows NT
Date: Fri, 27 Oct 2000 22:40:07 +0200
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2448.0)

------_=_NextPart_000_01C04056.1F523E30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Rick,

thanks for your answer. I actually forgot one line of code:

Instead of ...

  if (!hPrevInstance) {
    wndclass.style         =3D CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc   =3D WndProc;
    wndclass.cbClsExtra    =3D 0;
    wndclass.hInstance     =3D hInstance;
    wndclass.hIcon         =3D LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor       =3D LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground =3D GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName  =3D NULL;
    wndclass.lpszClassName =3D szAppName;
    RegisterClass (&wndclass);
  } /* if */

it had to be ...

  if (!hPrevInstance) {
    wndclass.style         =3D CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc   =3D WndProc;
    wndclass.cbClsExtra    =3D 0;
    wndclass.cbWndExtra    =3D 0;          <=3D=3D=3D=3D forgotten line
    wndclass.hInstance     =3D hInstance;
    wndclass.hIcon         =3D LoadIcon(NULL, IDI_APPLICATION);
    wndclass.hCursor       =3D LoadCursor(NULL, IDC_ARROW);
    wndclass.hbrBackground =3D GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName  =3D NULL;
    wndclass.lpszClassName =3D szAppName;
    RegisterClass (&wndclass);
  } /* if */

I think this does the same as you suggested.

I have another question, though. I know that this is not a mailing list =

on how to learn programming Windows, but maybe someone has
a quick answer here:

Petzold writes in his book, that when you move the thumb on a vertical  =

scrollbar, you receive a WM_VSCROLL message with wParam=20
SB_THUMBPOSITION when the mouse button is released.

 <<sysmets2.c>>  <<sysmets.h>>=20

When I inspect this piece of code (sysmets2.c, you also need sysmets.h =
to=20
compile it) with gdb and move
the thumb on the vertical scrollbar I always get 4 WM_VSCROLL
messages:

1. WM_VSCROLL message: wParam =3D 5 (SB_THUMBTRACK)

2. WM_VSCROLL message: wParam =3D arbitrarious (integer value > =
100.000, seems=20
to depend on how far the mouse was moved), lParam =3D 0

3. WM_VSCROLL message: wParam =3D arbitrarious (integer value > =
100.000, only=20
slightly different from 2. message), lParam =3D 0

4. WM_VSCROLL message: wParam =3D 8 (SB_ENDSCROLL), lParam =3D 0

When I simply tip on the thumb without moving it, I get 3 WM_VSCROLL =
messages:

1. WM_VSCROLL message: wParam =3D 5 (SB_THUMBTRACK), lParam =3D 0

2. WM_VSCROLL message: wParam =3D 4 (SB_THUMBPOSITION), lParam =3D 0

3. WM_VSCROLL message: wParam =3D 8 (SB_ENDSCROLL)

What I would expect from what Petzold writes is that I get everytime a=20
SB_THUMBPOSITION with the lParam containing the integer value of the=20
thumb position (range depending on the SetScrollRange Command issued
on WM_CREATE).

The book I got is 'Programming Windows 3.1', but the API cannot have =
changed
that fundamentally, can it?

When I compile the same source with my MSVC++ 16bit Standard Edition =
Compiler,
it works fine. But I have not debugged it now to have a look on the =
WM_VSCROLL
issued there.

Does anyone has any suggestions here?

TIA

Clemens Quoss

> Hi,=20
>=20
> I see the same behaviour.=20
> Zero the wndclass structure before you use it...add the following at =
around line 34=20
> memset (&wndclass, 0, sizeof(wndclass));=20
>=20
>=20
> Rick=20
>=20
> > -----Original Message-----=20
> > From: "Quo=DF, Clemens" [<mailto:clemens DOT quoss AT gzs DOT de>]=20
> > Sent: 25 October 2000 09:52=20
> > To: 'cygwin AT sources DOT redhat DOT com'=20
> > Subject: newbie question: hellowin on Windows NT=20
> >=20
> >=20
> >=20
> > Hello,=20
> >=20
> > [...]
> >=20
> > <<hellowin.c>> <<tocygwin.txt>> > >=20


------_=_NextPart_000_01C04056.1F523E30
Content-Type: application/octet-stream;
	name="sysmets2.c"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="sysmets2.c"

/*--------------------------------------------------------=0A=
  SYSMETS2.C -- Ermittlung der Ma=DFe des Systems, Version 2=0A=
                (c) Charles Petzold, 1992=0A=
  --------------------------------------------------------*/=0A=
=0A=
#include <windows.h>=0A=
#include "sysmets.h"=0A=
=0A=
#define NODOSTEXT // Quelltext im IBM-Zeichensatz=0A=
=0A=
void Oem_Ansi(char *OemStr, char *AnsiStr) {=0A=
#ifdef DOSTEXT=0A=
  OemToAnsi(OemStr, AnsiStr);=0A=
#else=0A=
  lstrcpy(AnsiStr, OemStr);=0A=
#endif=0A=
} /* Oem_Ansi */=0A=
=0A=
/* already defined in windef.h =0A=
=0A=
#define min(a,b) (((a) < (b)) ? (a) : (b))=0A=
#define max(a,b) (((a) > (b)) ? (a) : (b))=0A=
=0A=
*/=0A=
=0A=
long FAR PASCAL _export WndProc(HWND, UINT, UINT, LONG);=0A=
=0A=
/* added following code snippet to avoid warning when linking under=0A=
   cygwin */=0A=
=0A=
#ifdef __CYGWIN__=0A=
void WinMainCRTStartup() { mainCRTStartup(); }=0A=
#endif=0A=
=0A=
/* changed PASCAL to APIENTRY and HANDLE to HINSTANCE to get clean=0A=
   compile under cygwin =0A=
=0A=
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,=0A=
  LPSTR lpszCmdParam, int nCmdShow) {=0A=
=0A=
*/=0A=
=0A=
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,=0A=
  LPSTR lpszCmdParam, int nCmdShow) {=0A=
=0A=
  static char szAppName[] =3D "SysMets2";=0A=
  static char szWinTitle[40]; // Fenstertitel=0A=
  HWND hwnd;=0A=
  MSG msg;=0A=
  WNDCLASS wndclass;=0A=
=0A=
  if (!hPrevInstance) {=0A=
    wndclass.style         =3D CS_HREDRAW | CS_VREDRAW;=0A=
    wndclass.lpfnWndProc   =3D WndProc;=0A=
    wndclass.cbClsExtra    =3D 0;=0A=
    wndclass.cbWndExtra    =3D 0;=0A=
    wndclass.hInstance     =3D hInstance;=0A=
    wndclass.hIcon         =3D LoadIcon(NULL, IDI_APPLICATION);=0A=
    wndclass.hCursor       =3D LoadCursor(NULL, IDC_ARROW);=0A=
    wndclass.hbrBackground =3D GetStockObject(WHITE_BRUSH);=0A=
    wndclass.lpszMenuName  =3D NULL;=0A=
    wndclass.lpszClassName =3D szAppName;=0A=
    RegisterClass (&wndclass);=0A=
  } /* if */=0A=
=0A=
  Oem_Ansi("Ma=DFe des Systems, Version 2", szWinTitle); // =
Fenstertitel=0A=
  hwnd =3D CreateWindow(szAppName, szWinTitle, WS_OVERLAPPEDWINDOW | =
WS_VSCROLL,=0A=
    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, =
NULL, =0A=
    hInstance, NULL); =0A=
  ShowWindow(hwnd, nCmdShow);=0A=
  UpdateWindow(hwnd);=0A=
=0A=
  while (GetMessage (&msg, NULL, 0, 0)) {=0A=
    TranslateMessage(&msg);=0A=
    DispatchMessage(&msg);=0A=
  }=0A=
=0A=
  return msg.wParam ;=0A=
=0A=
} /* WinMain */=0A=
=0A=
long FAR PASCAL _export WndProc (HWND hwnd, UINT message, UINT wParam, =
=0A=
  LONG lParam) {=0A=
  static short cxChar, cxCaps, cyChar, cyClient, nVScrollPos;=0A=
  char szBuffer[50]; // f=FCr wsprintf und Oem_Ansi=0A=
  HDC hdc;=0A=
  short i, y;=0A=
  PAINTSTRUCT ps;=0A=
  TEXTMETRIC tm;=0A=
=0A=
  switch (message) { =0A=
    case WM_CREATE :=0A=
      hdc =3D GetDC(hwnd);=0A=
      GetTextMetrics(hdc, &tm);=0A=
      cxChar =3D tm.tmAveCharWidth;=0A=
      cxCaps =3D (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;=0A=
      cyChar =3D tm.tmHeight + tm.tmExternalLeading;=0A=
      ReleaseDC(hwnd, hdc);=0A=
      SetScrollRange(hwnd, SB_VERT, 0, NUMLINES, FALSE);=0A=
      SetScrollPos(hwnd, SB_VERT, nVScrollPos, TRUE);=0A=
      return 0;=0A=
=0A=
    case WM_SIZE :=0A=
      cyClient =3D HIWORD(lParam);=0A=
      return 0;=0A=
=0A=
    case WM_VSCROLL :=0A=
      switch (wParam) {=0A=
        case SB_LINEUP :=0A=
          if (nVScrollPos)=0A=
            nVScrollPos -=3D 1;=0A=
          break;=0A=
        case SB_LINEDOWN :=0A=
          nVScrollPos +=3D 1;=0A=
          break;=0A=
        case SB_PAGEUP :=0A=
          nVScrollPos -=3D cyClient / cyChar;=0A=
          break;=0A=
        case SB_PAGEDOWN :=0A=
          nVScrollPos +=3D cyClient / cyChar;=0A=
          break;=0A=
        case SB_THUMBPOSITION :=0A=
          nVScrollPos =3D LOWORD(lParam);=0A=
          break;=0A=
        default :=0A=
          break;=0A=
      } /* switch */=0A=
      nVScrollPos =3D max(0, (int)(min(nVScrollPos, NUMLINES)));=0A=
      if (nVScrollPos !=3D GetScrollPos(hwnd, SB_VERT)) {=0A=
        SetScrollPos(hwnd, SB_VERT, nVScrollPos, TRUE);=0A=
        InvalidateRect(hwnd, NULL, TRUE);=0A=
      } /* if */=0A=
      return 0;=0A=
=0A=
    case WM_PAINT :=0A=
      hdc =3D BeginPaint(hwnd, &ps);=0A=
      for (i =3D 0; i < NUMLINES; i++) {=0A=
        y =3D cyChar * (1 - nVScrollPos + i);=0A=
        TextOut(hdc, cxChar, y, sysmetrics[i].szLabel,=0A=
          lstrlen(sysmetrics[i].szLabel));=0A=
        Oem_Ansi(sysmetrics[i].szDesc, szBuffer);=0A=
        TextOut(hdc, cxChar + 22 * cxCaps, y, szBuffer, lstrlen =
(szBuffer));=0A=
        SetTextAlign(hdc, TA_RIGHT | TA_TOP);=0A=
        TextOut(hdc, cxChar + 22 * cxCaps + 40 * cxChar, y, szBuffer, =
=0A=
          wsprintf(szBuffer, "%5d", =
GetSystemMetrics(sysmetrics[i].nIndex)));=0A=
        SetTextAlign(hdc, TA_LEFT | TA_TOP);=0A=
      } /* for */=0A=
      EndPaint(hwnd, &ps);=0A=
      return 0;=0A=
=0A=
    case WM_DESTROY :=0A=
      PostQuitMessage(0);=0A=
      return 0;=0A=
  } /* switch */=0A=
  return DefWindowProc (hwnd, message, wParam, lParam) ;=0A=
} /* WndProc */=0A=
=0A=

------_=_NextPart_000_01C04056.1F523E30
Content-Type: application/octet-stream;
	name="sysmets.h"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="sysmets.h"

/*--------------------------------------------------=0A=
  SYSMETS.H -- Strukturdefinition f=FCr die Ergebnisse=0A=
               von GetSystemMetrics=0A=
  --------------------------------------------------*/=0A=
=0A=
#define NUMLINES (sizeof(sysmetrics) / sizeof(sysmetrics[0]))=0A=
=0A=
struct { int  nIndex ;=0A=
         char *szLabel ;=0A=
         char *szDesc ;=0A=
       } sysmetrics[] =3D {=0A=
=0A=
 {SM_CXSCREEN, "SM_CXSCREEN", "Bildschirmbreite"},=0A=
 {SM_CYSCREEN, "SM_CYSCREEN", "Bildschirmh=F6he"},=0A=
 {SM_CXVSCROLL, "SM_CXVSCROLL", "Breite vertikaler Rollpfeil"},=0A=
 {SM_CYHSCROLL, "SM_CYHSCROLL", "H=F6he horizontaler Rollpfeil"},=0A=
 {SM_CYCAPTION, "SM_CYCAPTION", "H=F6he der Titelleiste"},=0A=
 {SM_CXBORDER, "SM_CXBORDER", "Rahmenbreite"},=0A=
 {SM_CYBORDER, "SM_CYBORDER", "Rahmenh=F6he"},=0A=
 {SM_CXDLGFRAME, "SM_CXDLGFRAME", "Rahmenbreite von Dialogen"},=0A=
 {SM_CYDLGFRAME, "SM_CYDLGFRAME", "Rahmenh=F6he von Dialogen"},=0A=
 {SM_CYVTHUMB, "SM_CYVTHUMB", "H=F6he der Marke in =
Bildlaufleisten"},=0A=
 {SM_CXHTHUMB, "SM_CXHTHUMB", "Breite der Marke in =
Bildlaufleisten"},=0A=
 {SM_CXICON, "SM_CXICON", "Breite von Ikonen"},=0A=
 {SM_CYICON, "SM_CYICON", "H=F6he von Ikonen"},=0A=
 {SM_CXCURSOR, "SM_CXCURSOR", "Breite des Cursors"},=0A=
 {SM_CYCURSOR, "SM_CYCURSOR", "H=F6he des Cursors"},=0A=
 {SM_CYMENU, "SM_CYMENU", "H=F6he der Men=FCleiste"},=0A=
 {SM_CXFULLSCREEN, "SM_CXFULLSCREEN", "Breite vergr=F6=DFerter =
Fenster"},=0A=
 {SM_CYFULLSCREEN, "SM_CYFULLSCREEN", "H=F6he vergr=F6=DFerter =
Fenster"},=0A=
 {SM_CYKANJIWINDOW, "SM_CYKANJIWINDOW", "H=F6he von =
Kanji-Fenstern"},=0A=
 {SM_MOUSEPRESENT, "SM_MOUSEPRESENT", "Flag f=FCr \"Maus =
vorhanden\""},=0A=
 {SM_CYVSCROLL, "SM_CYVSCROLL", "H=F6he vertikaler Rollpfeil"},=0A=
 {SM_CXHSCROLL, "SM_CXHSCROLL", "Breite horizontaler Rollpfeil"},=0A=
 {SM_DEBUG, "SM_DEBUG", "Flag f=FCr \"Debug-Version\""},=0A=
 {SM_SWAPBUTTON, "SM_SWAPBUTTON", "Flag f=FCr \"Mauskn=F6pfe =
vertauscht\""},=0A=
 {SM_RESERVED1, "SM_RESERVED1", "Reserviert"},=0A=
 {SM_RESERVED2, "SM_RESERVED2", "Reserviert"},=0A=
 {SM_RESERVED3, "SM_RESERVED3", "Reserviert"},=0A=
 {SM_RESERVED4, "SM_RESERVED4", "Reserviert"},=0A=
 {SM_CXMIN, "SM_CXMIN", "Minimale Fensterbreite"},=0A=
 {SM_CYMIN, "SM_CYMIN", "Minimale Fensterh=F6he"},=0A=
 {SM_CXSIZE,  "SM_CXSIZE", "Breite der Zoom-Schaltfl=E4chen"},=0A=
 {SM_CYSIZE,  "SM_CYSIZE", "H=F6he der Zoom-Schaltfl=E4chen"},=0A=
 {SM_CXFRAME, "SM_CXFRAME", "Fensterrahmenbreite"},=0A=
 {SM_CYFRAME, "SM_CYFRAME", "Fensterrahmenh=F6he"},=0A=
 {SM_CXMINTRACK, "SM_CXMINTRACK", "Minimalbreite f=FCr =
Verschieben"},=0A=
 {SM_CYMINTRACK, "SM_CYMINTRACK", "Minimalh=F6he f=FCr =
Verschieben"},=0A=
 {SM_CXDOUBLECLK, "SM_CXDOUBLECLK", "Maximale X-Bewegung bei =
Doppelclicks"},=0A=
 {SM_CYDOUBLECLK, "SM_CYDOUBLECLK", "Maximale Y-Bewegung bei =
Doppelclicks"},=0A=
 {SM_CXICONSPACING, "SM_CXICONSPACING", "Horizontaler Abstand von =
Ikonen"},=0A=
 {SM_CYICONSPACING, "SM_CYICONSPACING", "Vertikaler Abstand von =
Ikonen"},=0A=
 {SM_MENUDROPALIGNMENT, "SM_MENUDROPALIGNMENT",=0A=
                                        "Men=FCs links oder =
rechts"},=0A=
 {SM_PENWINDOWS, "SM_PENWINDOWS", "PenWindows-Erweiterung =
installiert"}=0A=
  };  =0A=


------_=_NextPart_000_01C04056.1F523E30
Content-Type: text/plain; charset=us-ascii

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------_=_NextPart_000_01C04056.1F523E30--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019