Article View: borland.public.cppbuilder.nativeapi
Article #9118Re: Windows spacebar hotkey
From: Chris Croughton
Date: Tue, 03 Aug 2004 10:03
Date: Tue, 03 Aug 2004 10:03
104 lines
5975 bytes
5975 bytes
On 30 Jul 2004 08:48:57 -0700, Andrue Cope [TeamB]
<no.spam@spammy.com> wrote:
> No - the size is irrelevant. The user won't be able to see the
> component anyway. When the TEdit gets the focus I draw a border around
> the TBitmap. It looks to the user like the TBitmap has just got the
> focused but of course we know better (welcome to the inner circle of
> programming <g>).
Hmm, it won't let me give the focus to an invisible component, it pops
up an error box telling me so. (BCB6, incidentally, if that makes any
difference.)
> Hmmm:Golden rule of programming - the user only knows what you choose
> to tell them. We have an application that can get blocked on file I/O.
> In order not to look sluggish I tell the user that one particular
> process has finished when in fact it's only half way through. We
> actually designed the UI such that by the time user asks to view/use
> the results they will be ready anyway. Thus the users think we have
> some super duper highly efficient I/O code and we get to smirk a lot :)
Ah, but since I'm the main user for this (at the moment, anyway), /I/
know <g>. Personally, I'd rather have a progress bar which is accurate
(it's amazing how many aren't accurate). However, I'm very much in
favour of typeahead (and clickahead, I suppose), the ability to start
the input for the next operation before the current one has finished,
your system sounds like a version of that.
> But if the TEdit is not visible how can it get the focus? Answer;in two
> ways:
>
> 1.Tab/Cursor keys.
> It's enabled and flagged as visible so it's on the list. Press TAB
> enough times and it'll get the focus. The fact the user can't see it
> doesn't matter.
>
> 2.Someone clicks on the TBitmap.
> How does that work? Simple:I give it the focus in the mouse down
> handler for the TBitmap:
>
> void __fastcall TfrmViewer::imgBlockViewMouseDown(TObject *Sender,
> TMouseButton Button, TShiftState Shift, int X, int Y)
> {
> edtFakeFocus->SetFocus();
I've found a way to get something like what I want, though. If I have a
button (and the one I clicked to start the operation will do as well as
any), force everything else to give it the focus, and use the OnKeyDown
event of that, I can intercept everything except tab and the cursor
keys, and if within there I set Key to zero then it suppresses the usual
meaning of the key (even, I discovered, ALT-F4). Specifically, it
intercepts SPACE.
>> The form responds to OnKeyPress? How do you set it to do that?
>
> Ah, a further note on focus. If the component that has the focus
> doesn't respond to the message it gets sent on up to its parent
> component. In my code the focus edit box has no OnKeyPress/OnKeyDown
> handlers so the message is proprogated to its parent (a panel) and then
> for the same reason onto the form.
TEdit boxes seem to interpret keys themselves, though, to do their own
editing. Or can that be stopped?
>> Yup, "getting it working" is what I need.
>
> It can be a fine line. You don't want to write code without knowing why
> it works but nor should you waste time (IMO) figuring out the best
> possible solution. That's especially true in a RAD environment because
> otherwise IMO what's the point in using RAD? RAD is largely about
> getting the job done quickly. Win32 experts need not normally apply :)
Yup. As I said, I believe, I'm not a GUI programmer, I don't like GUIs
in general (for certain operations, like graphs, pictures, paintboxes
etc., they are of course useful) except that they allow me to run loads
of terminal (commandline) windows on the same screen. I'm not fond of
Win32 either, but certain things are easier (especially accessing
hardware the makers of which don't publish the interface).
>> The superstition paradigm: it worked when I did it that way once, so
>> I'll always do it that way <g>.
>
> Yeah - do you know the story about the woman who chopped the end off
> the meatloaf before cooking it because her mother always did it? When
> /her/ daughter asked why it turned out it had nothing to do with
> flavour - her own Mum just had a smaller oven at the time.
Heh. Lots of things like that ("I cut my finger and didn't have cloth
handy, so I wrapped spider web round it and it healed faster"). Some of
them (like the spider web) turn out to be valid, others (like bad luck
after seeing a black cat) aren't. I know a number of sysadmins who
don't understand how I get SCSI to work without sacrificing a goat
<g>...
> Again it's a balancing act. In this case I know it works. I know /why/
> it works and I have 27MB of other source code to worry about. You have
> to draw the line somewhere :)
Yup. In my case I want to do the job I want (most of my own software
(as opposed to that I'm paid for) I write for my own use, primarily, and
if anyone else finds it useful they are welcome to use it but it's not
written expecting anyone else to use it).
Chris C
Technical Details
Message-ID:
<slrncguooa.nl5.chris@ccserver.keris.net>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mailReferences:
<4107b926$1@newsgroups.borland.com> <4107c851@newsgroups.borland.com> <slrncgg2ei.f6p.chris@ccserver.keris.net> <4108b254$1@newsgroups.borland.com> <slrncghsd7.7ug.chris@ccserver.keris.net> <4108fd87$1@newsgroups.borland.com> <slrncgkkn7.9lp.chris@ccserver.keris.net> <410a6de9@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,af0a7a309a9df709 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Croughton <chris@keristor.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Windows spacebar hotkey Date: Tue, 3 Aug 2004 11:03:55 +0100 Lines: 104 Message-ID: <slrncguooa.nl5.chris@ccserver.keris.net> References: <4107b926$1@newsgroups.borland.com> <4107c851@newsgroups.borland.com> <slrncgg2ei.f6p.chris@ccserver.keris.net> <4108b254$1@newsgroups.borland.com> <slrncghsd7.7ug.chris@ccserver.keris.net> <4108fd87$1@newsgroups.borland.com> <slrncgkkn7.9lp.chris@ccserver.keris.net> <410a6de9@newsgroups.borland.com> Reply-To: chris@keristor.net X-Trace: news.uni-berlin.de Eb0cgFobPRwrVvzP452p8gHC1h3dTdE+71Uub+t43MQy/a2Gk= X-Orig-Path: ccserver.keris.net!news User-Agent: slrn/0.9.7.4 (Linux)