By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,928 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,928 IT Pros & Developers. It's quick & easy.

Using Handles.

P: n/a
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.

Jul 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.


Hello,

I think you are talking about handles in Windows

I found a very good explenation in the web:

"Handles are numbers which identify objects used by the operating system.
Windows, controls and menu items all have handles. Many of the WinFun
functions require you to pass a handle as a parameter to identify the
object on which you want to operate.

Handles are usually obtained using one of the following functions:
rnFindWindowByName, rnFindWindowByClass, rnGetButtonHandle,
rnGetMainMenuHandle or rnGetSubMenuHandle. Or if you are using COOL:Gen
and the object you want to operate on is a window or control in the
current procedure, you can use the COOL:Gen built in function GetHandle.
Other application development tools also offer handles as window and
control properties."

the short version:
handles are "like pointers" to objects like a window, button or something
else.
you need them to modify for example the caption of a button or resize a
window.

handles are a must for programming gui windows application, so you should
look
for some tutorials using google.

I hope you now understand it better

regards
Jul 23 '05 #2

P: n/a
Caglar Cakan wrote:
On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.

Hello,

I think you are talking about handles in Windows

[snip]
the short version:
handles are "like pointers" to objects like a window, button or something
else.
you need them to modify for example the caption of a button or resize a
window. We are off-topic here, nonetheless I'd like to add a remark:
Yes, in Windows a handle is something like a pointer, however there's
one
important difference:
In Windows a pointer refers to locked, unmovable (physical) memory,
a handle is a reference to memory managed by Windows which will move
the
real memory location if needed; you may consider a handle an index into
a lookup table that is managed by the OS (Windows).
That's why 2 group of functions are associated with handles:

the first one allows to lock and unlock the memory "behind" a handle,
something like (I don't remember the API exactly):
Window* lockWindow(HWND wnd);

the second ground copies the content of the handle's memory into a
local
variable (again it's too long ago I've been programming with Windows):
void getWindow(Window& dest, HWND wnd)
{
// pseudo implementation
Window* w = lockWindow(wnd);
dest = *w;
unlockWindow(wnd);
}
handles are a must for programming gui windows application, because the Windows API was definded this way ...
so you should look for some tutorials using google. BTW: also look at the memory allocation functions (other than new())
in the API, some of them return handles.
I hope you now understand it better

regards


Stephan Brönnimann
br****@osb-systems.com
Open source rating and billing engine for communication networks.

Jul 23 '05 #3

P: n/a

"Caglar Cakan" <no****@localhost.org> wrote in message
news:op.stwgbbd6vzko5k@sirkillalot...
On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.


Hello,

I think you are talking about handles in Windows

I found a very good explenation in the web:

"Handles are numbers which identify objects used by the operating system.
Windows, controls and menu items all have handles. Many of the WinFun
functions require you to pass a handle as a parameter to identify the
object on which you want to operate.


That's fine if he's talking about Windows handles, although I see nothing in
the post to suggest that (not having read the book).

On the Mac (at least in the older operating systems), a handle was a pointer
to a pointer. Like the indexing/lookup system used in Windows, this allowed
the operating system to move the location of the memory, because the handle
pointed to a pointer which the OS could update when it relocated the memory
block.

But I think that "handle" also has a somewhat more generic meaning, meaning
an object which holds some form of reference or pointer to another object.
But without reading the book, I'd be hard-pressed explaining what the author
meant by any of it. :-)

(As far as I know, "handle" isn't defined by the C++ language.)

-Howard

Jul 23 '05 #4

P: n/a
Caglar Cakan (no****@localhost.org) wrote:
: On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:

: > I have been reading Ruminations on C++, a very interesting book. They
: > are going into handles.

: I think you are talking about handles in Windows

I don't, and I have read the book.

Jul 23 '05 #5

P: n/a
Caglar Cakan wrote:
On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.


I think you are talking about handles in Windows


No, the book is by Koenig/Moo before they completly changed their mind
and became STL devotees. IIRC, handles mean something similar to what
is nowadays toutet as smart pointers.

Jul 23 '05 #6

P: n/a
Mr. Blackwell wrote:
Caglar Cakan wrote:
On Thu, 14 Jul 2005 08:01:04 +0200, enki <en*****@yahoo.com> wrote:
I have been reading Ruminations on C++, a very interesting book. They
are going into handles. I think what they are doing is very intersting
and very confusing. I have to read each paragraph several times to
understand.

I would like to understnad hgandles and find good uses for them or
better understand how they can make my programs better.


I think you are talking about handles in Windows


No, the book is by Koenig/Moo before they completly changed their mind
and became STL devotees. IIRC, handles mean something similar to what
is nowadays toutet as smart pointers.


After skimming the book again I must partly rectify my memory (I
remembered it as OO book in contrast to the later 'Accelerated C++'
which is a STL book). 'Ruminations on C++' already contains many STL
concepts. See also: http://homepages.kcbbs.gen.nz/nbree/ruminant.html

Jul 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.