Link to home
Start Free TrialLog in
Avatar of CodedK
CodedKFlag for Greece

asked on

Stop HTCLIENT acting like HTCAPTION

I have this code :

....Inherited;....
if Msg.Result = HTCLIENT then Msg.Result := HTCAPTION;
.....

It's usefull cause my form has no borders and i want to move it anyware on the screen.

I also have an image on the form with an "on click event" but it doesnt work cause the form acts like caption (..cant ''see'' the image).

I dont want to replace the image with a button or any other control.
Is there a way to get back focus on the image?

Also can u please give me some help with HT... ?
For e.x :
Form=HTCLIENT
Caption=HTCAPTION
Image= ? .......
 
ASKER CERTIFIED SOLUTION
Avatar of LRHGuy
LRHGuy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CodedK

ASKER

Thank you LRHGuy and Slick812.
LRHGuy code works fine (replaced message with msg)


  private
    { Private declarations }
    procedure WMNCHitTest(var Msg: TWMNCHitTest);
    message WM_NCHITTEST;
.......
........

procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;
  if (Msg.Result = HTCLIENT)
  and
  (ControlAtPos(ScreenToClient(SmallPointToPoint(TWMNCHitTest(Msg).Pos)),False)
  = nil)
  then
  Msg.Result := HTCAPTION;
end;


I think this code will work for u too Slick812.

But still this "WM_SysCommand, $F012, 0" and
(ControlAtPos(ScreenToClient(SmallPointToPoint(TWMNCHitTest(Msg).Pos)),False) = nil)
remains a mystery... Where can i find a list of WM.. commands and msg ???
There are several "System" message identifier (wParam) constants for the WM_SYSCOMMAND window message, examples of some you can use or test for are SC_MOVE, SC_CLOSE, and SC_KEYMENU . There are some others for hit test actions that are not generaly listed in the win32 Help for WM_SYSCOMMAND, these include -

SC_DRAGMOVE = $F012; // used if result of WM_NCHITTEST is HTCAPTION
SC_LEFTSIZE = $F001; // used if result of WM_NCHITTEST is HTLEFT
SC_RIGHTSIZE = $F002; // used if result of WM_NCHITTEST is HTRIGHT
SC_UPSIZE = $F003; // used if result HTTOP
SC_UPLEFTSIZE = $F004; // used if result HTTOPLEFT
SC_UPRIGHTSIZE = $F005; // used if result HTTOPRIGHT
SC_DNSIZE = $F006; // HTBOTTOM
SC_DNLEFTSIZE = $F007; // HTBOTTOMLEFT
SC_DNRIGHTSIZE = $F008; // HTBOTTOMRIGHT

as I understand the way this works, If you Left button Mouse Down on the Form (window) Caption (non button) the WM_NCHITTEST message is sent to the Form with the result as constanst HTCAPTION, then this WM_NCHITTEST message, HTCAPTION result is processed by the System, it will send the WM_SYSCOMMAND message to that same window (Form) with the wParam as SC_DRAGMOVE ($F012).

In the code you use for the WM_NCHITTEST message, you test for the HTCLIENT Result, and then change the Result to HTCAPTION. If the HTCAPTION Result is returned to the system, it will cause the system to send the WM_SYSCOMMAND message to the Form, with the wParam as SC_DRAGMOVE ($F012). . .

in my code I Skip all of the WM_NCHITTEST processing and go directly to what the system does anyway, perform the WM_SYSCOMMAND message, with the wParam as SC_DRAGMOVE ($F012) . . . .

if you want you can test this out by getting the WM_SYSCOMMAND and testing for the wParam as SC_DRAGMOVE , , with this code -

private
    { Private declarations }
    procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMMAND;

procedure TForm1.WMSysCommand(var Message: TMessage);
begin
if Message.WParam = $F012 then
  Label1.Caption := 'Got SC_DRAGMOVE wParam';
if Message.WParam = $F001 then
  Label1.Caption := 'Got SC_LEFTSIZE wParam';
inherited;
end;

if you drag your form by the caption or size it by the Left, the Label1 should change Captions. . . .

- - - - - - - - - - - - - - - - - -

You ask about other windows messages (and commands), there are many, many (more than a hundred) of system window messges, many of these listed in the Win32 API Help that comes with most versions of Delphi. You can start by looking in the Index for  "WM_A", and go down the list. . . . You can find thousands of  API functions  in the API Help also, but it would take a LONG time to cover all of the API methods and messages

Avatar of CodedK

ASKER

Thank you Slick812.
You helped me a lot man.
I know that it will take a long time... but i didnt even knew where to look.
This could be a start....
So.... thank you again.. :)
yea, the Win32 API Help is good to learn from, but there is so much in it, most do not know where to look.  . some tips for ya-

you might go to Index  "Messages and Message Queues" in the API Help and then you need to lclick the    >_>    title bar button at the top of the Help window, to go to the next page of that subject. .  there are several many pages to that subject. .

you may also want to look at Index  "Windows" and click the   >_>  button to read those pages