|
Thanks all,
One more thing, when i tried to execute a sample application ( with Direct X ) am getting the following error
especially with "strmif.h"
stating at
"typedef DWORD_PTR HSEMAPHORE; " as missing ;(semicolon)
also, unexpected end of file...
I have neither modified this file..nor did create this file..in VC 6 application.,
Can u guide me the root cause for this problem ? should i change/set any parameters for the same..??
Thanks in advance,
Pramod.
|
|
|
|
|
Hi all:
Recently I've been reading Charles Petzold's Programming Windows, but in the The GDI Mapping Mode chapter I encounter a few sentences for which I think they're contradict with each other. I'm sure It just because I'm just don't fully understand the priciple in it. But, for now it really confused me. So I hope if someone had readed this book or have a understanding about Mapping Mode can show me the way! The following is the excerpt for the book that confused me!
Charles Petzold said "If you change the viewport origin to (xViewOrg, yViewOrg), the logical point (0, 0) will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area."
given the code
<br />
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
and he says "This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2)"
Here's the confusion comes. the first line of code mapped the logical point (0,0) to the device point (0,0) which lies in the center after the call SetViewportOrgEx(...), I have no problem with that, but according to "If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0)" how's the (-cxClient / 2 ,-cyClient / 2) which is in the upper left corner mapped to the (cxClient/2, cyClient/2) which is in the lower right corner???? Since the device point (0,0) can't be changed, It always lies in the upper left corner??
note: the mapping mode is in the default!MM_TEXT
|
|
|
|
|
The mapping mode is a very funny thing in Windows. The thing which Peltzoid has forgotten to mention is that these two calls are mutually exclusive. You use the first or the second, but not both. Also, please forgive me if I am stating the obvious. I've used a very thick iron line in this bending process
Like Peltzoid says, the only thing you can do is determine how the logical points of the device context you draw to refer to the device points of the actual device. In short, how does (0,0) of the DC (which uses logical points) relate to the (0,0) of the actual device. The device point (0,0) is ALWAYS at the upper left hand corner of the device space. It does not change, ever.
For the example's sake, consider you have a window of measures 200 pixel width, 200 pixel heigth. SetViewportOrgEx allows, like stated, you to change the mapping of logical point (0,0) inside the device's space. If you command
SetViewportOrgEx(hdc, cxClient/2, cyClient/2, NULL);
the logical point (0,0) will refer to device point (100, 100) (cxClient = 200, cxClient/2 = 100) the exact center of the window. This call changed the mapping of logical point (0,0) to the device point(x,y) given as parameters. If you now called MoveTo(0,0) and LineTo(100, 0), the program would draw a horizontal line from the center of the window to the right hand edge.
In the other call, SetWindowOrgEx will allow you change the mapping of the logical point (x,y) inside the device's space. Following the same example, if you call
SetWindowOrgEx(hdc, -cxClient/2, -cyClient/2, NULL);
the logical point (-100,-100) (cxClient = 200, -cxClient = -200, -cxClient/2 = -100) will refer to device point (0,0). Doing simple math, where is logical point (0,0) now ? That's correct, in device point (100,100), which in our example is the centre of the window, again. This call changed the mapping of logical point (x,y), given as parameters to device point (0,0). If you used MoveTo(0,0) and LineTo(100, 0), you would again draw a line from the centre to the right hand edge.
The two calls were mutually exclusive: they did precisely the same thing. The changes done by the first one were overwritten with the second call.
Hope this helps you out
-Antti Keskinen
----------------------------------------------
"If we wrote a report stating we saw a jet fighter with a howitzer, who's going to believe us ?"
-- R.A.F. pilot quote on seeing a Me 262 armed with a 50mm Mauser cannon.
|
|
|
|
|
Hi,everyone
how to create a dialog which is not the main window, but its parent window and owner window are all NULL, such as the conversation window in MSN Messenger.
|
|
|
|
|
Make the parent window of each dialog as desktop window by calling GetDeskTopWindow()
-prakash
|
|
|
|
|
oh,it works!
Thanks very much.
|
|
|
|
|
in the "Handling Screen Savers" part of the platform SDK it says 2 functions "must be exported in the application's module-definition file." what is a definition file, and how do I make one for my project?
- thanks
|
|
|
|
|
|
.def is defintion file. Open a .def file ,you can define exported function in it.
|
|
|
|
|
hello
I need to make a program that is supposed to export data to a table like structure.I am coding in vc++ 6.0
Is there some way to dump all the data resulted from a program to a excel table or something
also, I have some experiences with list boxes in c, is there any way to make a list box have 2 collumns instead of just one or does this simply require 2 listboxes placed one next to another.
Is there another structrre besides the li9st box that I could use to display the resulting data in a table like form.
Any other suggestions about how a program like this might best be designed are also wellcomed. thank you
pLesae reply.
|
|
|
|
|
Spiritofamerica wrote:
Is there some way to dump all the data resulted from a program to a excel table or something
The easiest way is to write your data to a *.csv (comma seperated values) file. *.csv files are simple text files that are easy to create and are supported by most database and spread sheet programs out there.
Spiritofamerica wrote:
is there any way to make a list box have 2 collumns instead of just one
List boxes can be created with the LBS_MULTICOLUMN style, but I have never used a listbox that way. I use a ListView control instead when I want multiple columns.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
To use Excel function in VC++, you should first import Excel typelib From your office location and than use the code like:
CoInitialize(NULL); // Init COM
CLSIDFromProgID(L"Excel.Application",&clsid);
_Application ExcelApp; //Construct Excel object
if (FAILED(GetActiveObject(clsid, NULL, (IUnknown**)&pUnk)))
{
if (!ExcelApp.CreateDispatch("Excel.Application"))
{
AfxMessageBox("Failed to create Excel object!");
}
}
else
{
hr=pUnk->QueryInterface(IID_IDispatch, (void**)&pDispExcel);
ExcelApp.AttachDispatch(pDispExcel);
}
// and ...
See MSDN for detail reference.
Lisoft
|
|
|
|
|
If you use dialog display data , you can add List Control(not List Box) to the dialog.
|
|
|
|
|
Hi, Friend,
I have a edit control in a dialog. I initialize it to "Type Here". I also want to select "Type Here", and make it highlight.
I do this
//output text
m_ctlEdit->SetWindowText("Type Here");
//select all text
m_ctlEdit->SetSel(0,-1);
all works fine. but the "Type Here" won't highlight. I study CEdit, I could not find any method to highlight selected text.
Thank you
|
|
|
|
|
Is this[^] the effect you are after?
As for selecting the text, it works better if you place the SetSel(0, -1) code in the edit control's EN_SETFOCUS notification message handler.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Howdy all,
First off this board is great, thanks for everyone who helped me earlier.
I'm explicitly loading a DLL and constructing an object of type CTestDLL. In this class's constructor is the following code:
CTestDLL::CTestDLL()
{
fstream outfile;
cerr << "constructed";
outfile.open("c:\test.log", ios::app);
if (!outfile)
{
cerr << "could not open file";
exit(1);
}
}
It always fails to open, but the constructor's definitely being called. In addition to failing to open, I always get "the instruction at 0x00000000 referenced memory at 0x00000000. The memory could not be read".
I've tried creating the file manually, then trying to open it, with no luck. I've tried casting the const char* to a (LPCTSTR), using a CString, making the whole class visible, or just the individual methods (constructor/destructor) visible, all with the same results and same error.
Any ideas? I've googled and found others with the same problem, but unfortunately no answers. If I take the fstream code out the object contructs fine, but the fstream seems to muck things up.
|
|
|
|
|
change "c:\test.log" to "c:\\test.log"
must have double '\'
|
|
|
|
|
Thank you so much, what a silly mistake! What's weird is it fails even if I say "test.log" -- for some reason I have to state the drive.
|
|
|
|
|
Hi all:
Recently I've been reading Charles Petzold's Programming Windows, but in the The GDI Mapping Mode chapter I encounter a few sentences for which I think they're contradict with each other. I'm sure It just because I'm just don't fully understand the priciple in it. But, for now it really confused me. So I hope if someone had readed this book or have a understanding about Mapping Mode can show me the way! The following is the excerpt for the book that confused me!
*********************************************************
Here's how the functions work: If you change the viewport origin to (xViewOrg, yViewOrg), the logical point (0, 0) will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area.
For instance, suppose your client area is cxClient pixels wide and cyClient pixels high. If you want to define the logical point (0, 0) to be the center of the client area, you can do so by calling
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
The arguments to SetViewportOrgEx are always in terms of device units. The logical point (0, 0) will now be mapped to the device point (cxClient / 2, cyClient / 2). Now you can use your client area as if it had the coordinate system shown below.
00-y0|
00000|
0-----|----+x
00-x0|
00000|+y
(the origin shifted to the center, sorry for the zero because without them the coordinate will not be look like coordinate)
The logical x-axis ranges from -cxClient/2 to +cxClient/2, and the logical y-axis ranges from -cyClient/2 to +cyClient/2. The lower right corner of the client area is the logical point (cxClient/2, cyClient/2). If you want to display text starting at the upper left corner of the client area, which is the device point (0, 0), you need to use negative coordinates:
TextOut (hdc, -cxClient / 2, -cyClient / 2, "Hello", 5) ;
You can achieve the same result with SetWindowOrgEx as you did when you used SetViewportOrgEx:
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ; //ok know problem, the (-cxClient / 2, -cyClient / 2) is changed to the device point (0,0), I understand that
The arguments to SetWindowOrgEx are always in terms of logical units. After this call, the logical point (-cxClient / 2, -cyClient / 2) is mapped to the device point (0, 0), the upper left corner of the client area.
What you probably don't want to do (unless you know what's going to happen) is to use both function calls together:
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
//from what I'm understanding, after the logical point (0,0) mapped to veiwport center the SetWindowOrgEx (...) will make the point already in the upper left corner mapped to the device point (0,0) which is also at left corner (0,0)
This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2), giving you a coordinate system that looks like this:
00000000000000-y|
0000000000000000|
00000000000-x-----|
(the origin shifted to the lower right corner, but I think it should be at the upper left corner, why why why?)
I don't know how's the origin shifted to lower right corner. given that If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0)
I think the origin will shifted to the upper left corner.
Beside if you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), then I think It will be no matters regarding how you specify you window origin because It always be shifted to device point (0,0) which is upper left corner and it contradict with the second picture.
|
|
|
|
|
The easiest way to make sense of these type of things is to see them in action. So make a simple SDI test app and insert the follow code in the OnDraw function
void CSDITestView::OnDraw(CDC *pDC)
{
CSDITestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetViewportOrg(50, 50);
pDC->SetWindowOrg(50, 50);
pDC->Rectangle(0, 0, 100, 100);
} Now play with the code. Comment out the SetViewportOrg and SetWindowOrg lines, change the values passed to them, etc and run the program to see what happens. You will notice that the rectangle, which you are suppose to be drawing at location 0, 0 will be drawn at different locations depending on the values passed to the Set* functions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I have written a program in C++. When I run the program it gives me an exe file. I would like to know what code I can enter which would give the user the option to print the output. Forward slashes represent the code I entered. I get many errors with this code. If you need the rest of the programs code to assist me let me know and I will send it.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using std::cout;
using std::cin;
using std::fixed;
using namespace std;
//#include
int main() //(int,char*)
//{
//ofstream printer ("1pt1:");
//Printer <<"test"<
|
|
|
|
|
BRIMID wrote:
//ofstream printer ("1pt1:");
//Printer <<"test"<<endl;
return="" o;<="" i="">
The first letter in "lpt1" is a lower case 'L' not a one. C++ is case sensitive in variable names: printer vs Printer. main() has to return an integer 0 (zero) not the letter 'o'.
ps. when posting code your include files are being dropped. What you should do is click on the "Do not treat <'s as HTML tags" check box that is located immediately below the text edit window used to enter messages.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
This is the code and it does not work. I am getting 5 error messages when compiling. If someone could give me assistance from //#include to //{ I would appreciate it. Do I have the function in the right place? That sort of thing. You guys have really been helpful.
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
using std::cout;
using std::cin;
using std::fixed;
using namespace std;
//#include
int main() //(int,char*)
//{
//ofstream printer ("lpt1:");
//Printer <<"test"<<endl;
// return 0;
//}
{
int c;
double fee;
double total;
char a ='y', ans;
string input;
int number;
Thanks
|
|
|
|
|
i want to develop an exe (by VC++) which contains icons of 256 colors, how to do that? is it possible?
includeh10
|
|
|
|
|
Yes, it is possible. But if you want to edit icons with any more than the basic 16 colours you have to use another graphic editor, not the one supplied with visual studio. Create your icon in the other editor and then import it into your project.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|