Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Stop HTCLIENT acting like HTCAPTION

Posted on 2004-10-02
6
Medium Priority
?
766 Views
Last Modified: 2010-04-05
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= ? .......
 
0
Comment
Question by:CodedK
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
LRHGuy earned 300 total points
ID: 12206945
Anything dereived from a TControl returns HTCLIENT unless it shouldn't (meaning it's been overridden.)

You most likely will have to check the hit point yourself, and only set HTCAPTION when you know there is no control at the point. Something similar to:

if (Message.Result = HTCLIENT)
and (ControlAtPos(ScreenToClient( SmallPointToPoint(TWMNCHitTest(Message).Pos)), False)= nil)
then
          Message.Result := HTCAPTION;

I haven't tested that, but I think it'll work.
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 180 total points
ID: 12208237
hello CodedK, I have tried to use the HTCAPTION as a way to get a drag form on Client area, but I had proplems with it, the method I use now is with the Forms's OnMouseDown Event, get your OnMouseDown event and add this code -


procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbLeft) then
  begin
  ReleaseCapture;
  Form1.perform(WM_SysCommand, $F012, 0);
  end;
end;

this will allow to to Click other controls (and TImages) on your form. . .
If the TImage you talk about the click event, covers the entire form, then you may have problems
0
 
LVL 16

Author Comment

by:CodedK
ID: 12211002
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 ???
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 34

Expert Comment

by:Slick812
ID: 12219857
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

0
 
LVL 16

Author Comment

by:CodedK
ID: 12225379
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.. :)
0
 
LVL 34

Expert Comment

by:Slick812
ID: 12229335
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
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question