Self-made cursors over self-made buttons (The Real Mission Impossible!) ?? 
Author Message
 Self-made cursors over self-made buttons (The Real Mission Impossible!) ??

Hello,

Some times ago, I posted a question where I explained, that in my program
my self-made cursor doesn't work when passing over self-made buttons,
windows-buttons (OK, Cancel, ...) and radiobuttons in my windows (build
with the TPW-Workshop). Every time, when I make a little movement over a
button, the self-made shape of my mousepointer changes into the
windows-arrow. Otherwise, in the othere places of the windows, there are
no problems with the self-made pointer.
Programmers answered me (thanks again!) to look for WM_SetCursor, but
even with this hint I can't get it right. Others told me, that when
writing '0' instead of 'HWindow' -or the window in where the buttons
occur (?)-, when initializing the cursor, it must work. But: no result!  
:-(
Some information about my program, one part, where I create a window
(EndWindow) that has the problem with buttons as described above:
Type
  TApp = object(TApplication)
    procedure InitInstance; virtual;
    procedure InitMainWindow; virtual;
  end;

  PMyMainWindow = ^TMyMainWindow;
  TMyMainWindow = object(TWindow)
    ...
    procedure WMSetCursor(var Message: TMessage); virtual wm_first +  
wm_SetCursor;
  end;

  PEndWindow = ^TEndWindow;
  TEndWindow = object(TDialog)
  {This window is similar to the window you get when closing your
Windows, it  gives also the text 'This will
close...' + 2 buttons (Yes/No)}
  {On these buttons I can't see my own cursor}
    ...
    procedure WMSetCursor(var Bericht: TMessage); virtual wm_first +
wm_SetCursor;
  end;

   ...
procedure TMyMainWindow.WMSetCursor(var Message: TMessage);
    ...
    begin
      SetCursor(LoadCursor(hInstance, 'CURSOR2'));
      CaseA := True;
    end
  else SetCursor(LoadCursor(hInstance, 'CURSOR1'));
  end;
  {Here, in the main window I build some hypertext, this changement works
perfectly}

   ...
procedure TEndWindow.WMSetCursor(var Message: TMessage);
begin
  SetCursor(LoadCursor(hInstance, 'CURSOR1'));
end;

What I found later is, that when making the buttons in my program,
instead of making them via the Workshop, the problem 'seems' to be
solved. I wrote this:

constructor TEndWindow.Init;
begin
  TDialog.Init(AParent, Title);

{id_Agree = id of my self-made button}
end;

procedure TEndWindow.SetUpWindow;
begin
  TDialog.SetupWindow;
  SetClassWord(MyButton.hWindow, gcw_hCursor, LoadCursor(hInstance,
'CURSOR1'));
end;

Here, my self-made cursor doesn't change to the windows-arrow, when
passing over that button (in that window). It doesn't even change
anymore, when passing over the other buttons (in that Window), created
with the Workshop!!  :-\ . But, pushing on every button (in that window),
gives as result a Run-Time-Error
204, and ends the program.

What did I wrong, and what is the solution?
       Thanks in advance!



Wed, 18 Jun 1902 08:00:00 GMT  
 Self-made cursors over self-made buttons (The Real Mission Impossible!) ??

Hello,

Some times ago, I posted a question where I explained, that in my program
my self-made cursor doesn't work when passing over self-made buttons,
windows-buttons (OK, Cancel, ...) and radiobuttons in my windows (build
with the TPW-Workshop). Every time, when I make a little movement over a
button, the self-made shape of my mousepointer changes into the
windows-arrow. Otherwise, in the othere places of the windows, there are
no problems with the self-made pointer.
Programmers answered me (thanks again!) to look for WM_SetCursor, but
even with this hint I can't get it right. Others told me, that when
writing '0' instead of 'HWindow' -or the window in where the buttons
occur (?)-, when initializing the cursor, it must work. But: no result!  
:-(
Some information about my program, one part, where I create a window
(EndWindow) that has the problem with buttons as described above:
Type
  TApp = object(TApplication)
    procedure InitInstance; virtual;
    procedure InitMainWindow; virtual;
  end;

  PMyMainWindow = ^TMyMainWindow;
  TMyMainWindow = object(TWindow)
    ...
    procedure WMSetCursor(var Message: TMessage); virtual wm_first +  
wm_SetCursor;
  end;

  PEndWindow = ^TEndWindow;
  TEndWindow = object(TDialog)
  {This window is similar to the window you get when closing your
Windows, it  gives also the text 'This will
close...' + 2 buttons (Yes/No)}
  {On these buttons I can't see my own cursor}
    ...
    procedure WMSetCursor(var Bericht: TMessage); virtual wm_first +
wm_SetCursor;
  end;

   ...
procedure TMyMainWindow.WMSetCursor(var Message: TMessage);
    ...
    begin
      SetCursor(LoadCursor(hInstance, 'CURSOR2'));
      CaseA := True;
    end
  else SetCursor(LoadCursor(hInstance, 'CURSOR1'));
  end;
  {Here, in the main window I build some hypertext, this changement works
perfectly}

   ...
procedure TEndWindow.WMSetCursor(var Message: TMessage);
begin
  SetCursor(LoadCursor(hInstance, 'CURSOR1'));
end;

What I found later is, that when making the buttons in my program,
instead of making them via the Workshop, the problem 'seems' to be
solved. I wrote this:

constructor TEndWindow.Init;
begin
  TDialog.Init(AParent, Title);

{id_Agree = id of my self-made button}
end;

procedure TEndWindow.SetUpWindow;
begin
  TDialog.SetupWindow;
  SetClassWord(MyButton.hWindow, gcw_hCursor, LoadCursor(hInstance,
'CURSOR1'));
end;

Here, my self-made cursor doesn't change to the windows-arrow, when
passing over that button (in that window). It doesn't even change
anymore, when passing over the other buttons (in that Window), created
with the Workshop!!  :-\ . But, pushing on every button (in that window),
gives as result a Run-Time-Error
204, and ends the program.

What did I wrong, and what is the solution?
       Thanks in advance!



Wed, 18 Jun 1902 08:00:00 GMT  
 Self-made cursors over self-made buttons (The Real Mission Impossible!) ??

Quote:

>Hello,
>Some times ago, I posted a question where I explained, that in my program
>my self-made cursor doesn't work when passing over self-made buttons,
>windows-buttons (OK, Cancel, ...) and radiobuttons in my windows (build
>with the TPW-Workshop). Every time, when I make a little movement over a
>button, the self-made shape of my mousepointer changes into the
>windows-arrow. Otherwise, in the othere places of the windows, there are
>no problems with the self-made pointer.
>Programmers answered me (thanks again!) to look for WM_SetCursor, but
>even with this hint I can't get it right. Others told me, that when
>writing '0' instead of 'HWindow' -or the window in where the buttons
>occur (?)-, when initializing the cursor, it must work. But: no result!  
>:-(
>Some information about my program, one part, where I create a window
>(EndWindow) that has the problem with buttons as described above:

[code snipped]

Quote:
>What I found later is, that when making the buttons in my program,
>instead of making them via the Workshop, the problem 'seems' to be
>solved. I wrote this:

[code snipped]

Quote:
>Here, my self-made cursor doesn't change to the windows-arrow, when
>passing over that button (in that window). It doesn't even change
>anymore, when passing over the other buttons (in that Window), created
>with the Workshop!!  :-\ . But, pushing on every button (in that window),
>gives as result a Run-Time-Error
>204, and ends the program.

I beleive run-time error 204 has to do with manual creation of
buttons, not with setting the cursor. :)

OK, let's go...

When you create your dialogs in Resource Workshop you are using
default windows or BWCC window classes. This classes have class
cursors which is set to default windows cursor (arrow).
BP help - function SetCursor() - 'Any application that must set the
cursor while it is in a window must ensure that the class cursor for
the given window's class is set to zero. If the class cursor is not
zero. the system restores the previous shape each time the mouse is
moved.'
Here you go, this is your problem with Resource Workshop dialogs...

Now let's check creation of your own buttons.

procedure TEndWindow.SetUpWindow;
begin
  TDialog.SetupWindow;
  SetClassWord(MyButton.hWindow, gcw_hCursor, LoadCursor(hInstance,
'CURSOR1'));
end;

Hmmm, you set the cursor for the CLASS, not for the button, so all
windows with that class will have now 'CURSOR1' style. OK, another
mystery solved :) ( BTW, I hope you are calling DestroyCursor for
'CURSOR1'...)

I'm not sure about correct solution, but the quick fix is - still
create all the dialogs in resource workshop and change class cursor in
TEndWindow.SetupWindow method as before. Watch out - there are traps
in this fix. First, if you are using BWCC all BWCC buttons in all
programs will have your cursor style, otherwise (without BWCC) all
buttons will have it (at least I think so, I'm not sure). Second,
according to good style of windows programming you should deallocate
all resource upon program termination, including this loaded cursor
and I'm not sure what will happen if you just destroy it without
restoring class cursor...
Second not so quick fix is to create custom button class and create
buttons with your style...

Cheers
  Dmitri

P.S Just an idea - you could try to set class cursor to zero and
respond to wm_SetCursor messages, then buttons in other applications
would be less affected, but IMHO not-so-quick-fix is better, unless
somebody has other solution :)

--------------------------------------------------------------
        Shit happens, but why it always happens to us?
--------------------------------------------------------------

                            http://www.dma.be/p/bewoner/dmitri



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. self-made cursor above windows-button?

2. Self-made mouse-shape over buttons ??

3. Self-Made Programs

4. Programming a self-made cursor on a windows-button?

5. Programming a self-made cursor above a windows-button?

6. Making Buttons Disabled.

7. Making the TColumn.ButtonStyle button appear on entering the column cell

8. Making a button in Acrobat Reader 3.0 with Delphi

9. making the blinking cursor dissapear

10. Self-contained db + exe

11. Self Login dialog box

12. self-executing programs

 

 
Powered by phpBB® Forum Software