Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Stop HTCLIENT acting like HTCAPTION

Posted on 2004-10-02
6
Medium Priority
?
744 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

715 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