|
Device Units / Coordinates:
Device units are the actual units of the device context. This would be pixels.
Logical Units / Coordinates:
Since different devices have different resolutions, windows allows programmers to define Logical units in order to make the graphics programming more device independant. Logical units are also called the page coordinate space. This allows the programmer to define the units that they would like to work with instead of pixels. For instance, say you are writing a landscaping program, you could define the base unit as 1/8 inch.
WindowExtent:
This is a value that indicates what units that you would like to work with.
ViewportExtent:
The size of the viewport that the WindowExtent will be mapped to. Say you wanted to make a mini-view of a document, you would set the WindowExtent to the size of the document regularly, and the Viewport extent to the size of the mini view. Then you use the same paint code, and you will have a mini-view of your document.
Dots / Inch:
This is the resolution of your printer or display device. Usually monitors aren't measured like this so I will explain printers. A fairly standard resolution for printers is 600 dpi, which is 600 dots / inch. You can think of this as 600 pixels / inch. If you left you DC that you received from your printer as the default, you would be painting each individual pixel, but since you set the window extent and the viewport extent, the logical or page coordinates get remapped to allow you to paitn your graphic on the entire page.
There is alot of information in MSDN and in Charles Petzolds Windows programming book.
|
|
|
|
|
Consider the following section of code:
int a = 10;
int* b;
Which of the following statements places the address of a in b. Remember, more than one of these options may be correct. In your response, explain which ones work and why, and also explain why the incorrect answers will not work. I want more than a listing of the syntax errors!
b = a;
b = &a;
b = *a;
*b = a;
&b = &a;
Loli10
|
|
|
|
|
|
Not quite. It's something that came up in lecture. My homework is writing a program.
Loli10
|
|
|
|
|
Loli10:
b=a; will give compile time error becasue it is not legal to assign the int value from a to the pointer value in b.
b=&a; this moves the address of a to the pointer variable b....the answer you were looking for.
b=*a; this is not legal because *a means get contents pointed to by a and yet a is not a pointer variable.
*b = a; this is a legal statement IF b has a valid pointer in it. If so then the value of a is moved to the integer pointed to by b.
&b=&a; this is not legal becasue it does not make logical sense to use the & address of operator on the left side of an = sign.
Mike
|
|
|
|
|
Thanks Mike - it makes sense!
Loli10
|
|
|
|
|
Hi all
I have created an ATL 7.0 service with a simple COM object in it. The service is multithreaded (_ATL_FREE_THREADED defined and my coclass has the threading("free") attribute).
The problem is that when a client tries to create an instance of the object, it gets the error number 0x80080005 (Server execution failed). This error occurs in the CoGetClassObject call. When this error occurs, I get the following message in the system event log:
The server {50DDF6F0-0A98-4126-9D38-606FE167C56F} did not register with DCOM within the required timeout.
Not that this is the GUID of the module.
I don't try to create the object via DCOM. I don't have this problem if I don't register the exe as a service (a standalone exe COM server).
Tx for the help!
Michel
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|
|
Hi,
It seems that whenever I get going on a large project I always get tangled up in #include header file issues. I've looked around the internet for articles to learn more about where I should put the headers in the first place but I have not turned anything up.
Could some of you share your experinces and send links on this topic?
PS: I did find an article: _Creating your own GUIDs_ here on codeproject that covers multiple inclusion which was nice but I'm looking for a little bit more on the general topic.
|
|
|
|
|
Always I create groups of functions that are declared in different headers. I prefer to work with classes, and I put the declaration of the class in hader, (one header per class) other peoples prefer to put two or more classes in the same header, deppendong the size of the size, but I prefer to use one header per class, for me is comfortable, and easy to find functions, when I know in what class is.
For me is important because I sahre the classes between diferent projects, In that case I include only the class that I am interesting for...
Is dificult to find a rule, is difficult to find a because, every develpper works the different way, but always you can find a group of developer that prefer to work in that mode...
Best Regards.
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Read John Lakos' "Large Scale C++ Software Design". This book deals mostly with physical (not logical) design issues, like header files etc.
The rule of the thumb with non-trivial projects is: do not #include anything just because it's convenient. Use forward declarations wherever possible.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz Sowinski wrote:
Use forward declarations wherever possible.
Very true
My and my colleagues one time optimized the compile time to 20% of total time, it took 1º time 25 minutes , and after optimizing only 5 minutes
Cheers,
Joao Vaz
|
|
|
|
|
Joao Vaz wrote:
it took 1º time 25 minutes , and after optimizing only 5 minutes
Ha! So it was actually a pessimization! How did you achieve that? You've only replaced #includes with forward refs??
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Tomasz Sowinski wrote:
So it was actually a pessimization
I said compile time , not run time !!!
Basically , a mixture of pimpl idiom , with changing all graphic widgets to widgets*.
Now, if you think it's weird, I agree with you, we only changed the a special debug version to show up to the rest off the company, we had every single friday a presentation to show the job done since the last week.
So the time it took 25 minutes to compile, achieved that we were late 30 minutes , what didn't do any good to us, I know what I'm talking a about, the project had 3 programmers, including me, the programmer manager wasn't a programmer manager at all , we coded month after month afterhours, we were seen in the company as the black sheep, they didn't do any planning and they said that wasn't needed , so they reformulated week after week the aplicational requirements
The app had more than 100+ screens , hundreds of classes , 120 tables , more than 500 stored procedures(and logaritmic increasing), some extremely complex, like a 1000 lines that I wrote ... and they f***ed expected some <<little changes="">> didn't break the code .
Oh, and more , in the company was forbidden to listen to the music, even with speakers, we were obliged to wear a full suit with a tie, even we never leave to clients, and we unofficially the maintainers of the network for the company, including installing win98 and games to the director ... but they never accounted on this for the delays on our planning,even I losted 2 days on resolving the problems with the network , helping the others employees to do their work that was also very important ...they never gave a f***, they said that was our guilty
Result : we resolve to above solution to decrease compile time, it's so much faster to include the header in the cpp than in the header, much faster indeed
Of course, eleven months after we all resigned and leaved the company to frooze the product
They well deserved
Joao Vaz
|
|
|
|
|
There are some tips discussed in Herb Sutter exceptional and more exceptional C++. Guidelines that may reduce the include hell are:
* use forward delarations. The author stresses the use of #include < iosfwd >
* Avoid unnecesary inheritace. "is implemented in terms of". By encapsulating data members (pointers wrapped in a convenient smart pointer like std::auto_ptr or boost::shared_ptr ).
* The pimpl idiom.
For further details go to www.gotw.ca (lots of C++ good material there) and even better, support the author by buying his book (I'm in no way related to the author, but I do enjoy reading his columns...)
Regards,
R.
|
|
|
|
|
Ramon Casellas wrote:
For further details go to www.gotw.ca (lots of C++ good material there) and even better, support the author by buying his book (I'm in no way related to the author, but I do enjoy reading his columns...)
Very True , a indispensable portal of knowledge to any serious c++ developer .
I've Exceptional C++, but I didn't bought yet The More Exceptional C++
Joao Vaz
|
|
|
|
|
One thing I always do, and I picked this up from reading windoze SDK headers, is I put this little block at the front of all my headers :
#ifdef _HEADER_H
#error repeated include of this file
#else
#define _HEADER_H
#endif
Then substitute the name of your header file in place of HEADER.
Any time I want to include the file I use this :
#ifndef _HEADER_H
#include "Header.h"
#endif
This forces one and only inclusion of a given header file without having to parse each one a whole bunch of times. This really adds up in large projects.
One key to making this work is to have a consistent define pattern for the header files. I always use the one shown. I dislike the GUID method but that's just me.
This is also portable unlike MFC's pragma once method in case that matters.
Another frequent header file headache is the issue of global variables and the use of extern. Here is what I do.
In one central macro definition header define this :
#ifdef _DEFINE_GLOBALS
#define Global
#else
#define Global extern
#endif
Then you can declare global variables like this :
Global int GlobalInteger_1;
Global int GlobalInteger_2;
If you want them initialized then do this :
#ifdef _DEFINE_GLOBALS
int GlobalInteger_1 = 42;
#else // _DEFINE_GLOBALS
Global int GlobalInteger_1;
#endif // _DEFINE_GLOBALS
Prior to include the header with the global declarations, do this :
#define _DEFINE_GLOBALS
#include "Globals.h"
NOTE: the _DEFINE_GLOBALS may only be defined one and only one time. I usually do it in my application class module.
The advantages of this scheme are that you only have to maitain one file of declarations and the extern issue is taken care of.
|
|
|
|
|
Hi
First of all a short description of what I want to do:
I want to start a program (using ShellExecute), then find the only ListBox within the new launched app. I use FindWindow and then EnumChildWindows.
Until now everything works fine, I can get a HWND handle to the ListBox of the other app.
Now I want to select the 2nd item of the single-selection ListBox.
I use
SendMessage(hwnd,LB_SETCURSEL,1,0);
The ListBox definately has at least 2 items and the hwnd handle is correct as well. However, no item is selected, although it should work this way (MFC does it the same way).
If I try
int count = SendMessage(hwnd,LB_GETCOUNT,0,0);
this works, i.e. I can get the numer of items of this ListBox.
Can you explain, why I can't change the selected item?
thanks in advance
Gregor
modified 12-Sep-18 21:01pm.
|
|
|
|
|
LB_SETCURSEL only works for single selection list boxes. If the list box supports multiple selection, use LB_SETSEL instead.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
As I said in my first post this is a single selection listbox
Help Me!
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Ooops sorry, didn't see that!
What's the return value of SendMessage() ? Does it return LB_ERR ?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
It returns "1".
Dunno what that means but shout mean that item 1 has been selected, right?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hmmm, looks like it's doing the right thing.
Have you tried selecting (i.e. setting focus to) the window containing the list box after you do the SendMessage() ? Does it show the highlighted item when you do that?
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
It automatically gets focus after it has been launched through ShellExecute
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I just found a very strange behavior:
If I start my app for the first time, the item does not get selected in the listbox of the app.
But if I start my app for a second time (and therefore my program starts the other program again so that two instances are running), then suddenly the item gets selected, but only in the first (!) instance of the other app.
What's going on?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Can you use Spy++ to check if your listbox actually receives LB_SETCURSEL?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|