|
Wow - you're not even attempting to disguise this "do my assignment for me" request.
You've got a lot of gall (and probably no future in software development).
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB, C#, or Java to C++/CLI
Java to VB & C# Converter: convert Java to VB or C#
|
|
|
|
|
|
I'd like to save the HDC content obtainbed from GetPrinterDC (which has just one ellipse drawn on it) to a .EMF file, I've tried with a window HDC and it works fine, but the same do not occurs with the printer related HDC.
The function I've used for tests is below.
Thanks for any tip !
void PrintStuff( HWND hWndParent )
{
HDC hDC;
DOCINFO di;
hDC = GetPrinterDC();
InitDocStruct( &di, "MyDoc");
StartDoc( hDC, &di );
StartPage( hDC );
HPEN newPen = CreatePen(PS_SOLID,50,RGB(0,0,0));
HPEN oldPen = (HPEN)SelectObject(hdc,newPen);
Ellipse(hdc, 0, 0, 200, 200);
******** I'D LIKE TO SAVE HDC TO AN EMF HERE
EndPage( hDC );
EndDoc( hDC );
DeleteDC( hDC );
}
|
|
|
|
|
I don't believe that will necessarily work with a printer DC, since the GDI commands sent
to the DC may go right through to the driver. So, for example, you can't read back a bitmap
from a printer DC.
Can you draw to the metafile DC?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The interest is, as you said, to read back a bitmap\emf from the printer DC, because the real context that my code will work in is inside a Printing API (EndPage probably) hook. The final idea is to read details about what's being printed, these details must be addressed at the EMF level. This is part of my requirements.
If the EMF can't be generated just from the Print HDC, I'll have more problems that I could imagine initially.
Anyway, thanks a lot for the prompt reply.
|
|
|
|
|
I personally would put the rendering code in a separate function/method that gets passed a DC.
That way the drawing code only needs to be written once....you can call the method with a metafile DC,
a printer DC, etc.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, this is the way if I was writing a regular app, but I'm writing a completely different thing: a hook at a lower level, so everything I have is a Printer HDC received from an unknown app
Thanks again.
|
|
|
|
|
hi guys
does any body know or have some easy and good sample or tutorial about system api hooking, with out PE hooking and assembly,
tried to search for but could nt get an easy to understand one.
may be the messagebox
like my doubt is say i run my app which will replace hook the messagebox of user32.dll to my own defined messagebox, which will be global, so any app tht calls messagebox pre or post app after my hook should call my own messagebox
is it needed to write a driver to hook system apis,
Thanks
S
|
|
|
|
|
so no one here knows bout hooking?????????????/
|
|
|
|
|
God. What a rude little oik you are. Did you not get the memo that this is a volunteer only site and that people with rude little attitudes just end up getting ignored? BTW - hooking has a different meaning as well. You may want to change that little bit of attitude.
|
|
|
|
|
thanks will keep in mind in future, now please the solution
|
|
|
|
|
|
|
I am trying to parse dbf file. I was not able to open it via ODBC
so I do direct reading from it. It is dBase 7
I have problem with double data type
Structure description said
"O" Double 8 bytes - no conversions, stored as a double.
http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm
But it is not IEEE Standard 754 i guess
and I just wonder how this double is stored in memory
and how to read it or decode.
For example:
-0.48 is stored:
21 47 AE 1F FF FF FF C0
and +0.48 is stored:
DE B8 51 E0 00 00 00 C0
It is almost like IEEE 754, numbers bigger than 1 works fine
41.84 is
44 EB 85 20 00 00 00 40
if read in order (last byte is first)
40 44 EB 85 20 00 00 00
but where is the different?
Does anyone know what I am talking about
Is there any memory specification or library for floating point in dBase?
Thank you
viliam
|
|
|
|
|
Why don't you just read the double from the file to memory and print it with printf or some other function? Then you should see if it is IEEE 754 (and I'm expecting that it is).
Don't try it, just do it!
|
|
|
|
|
hi, I try it - doesn't work well.
I am afraid that this double value is some modification of IEEE 754
Because file is dBase7 I can not read it in ODBC so
I just open this file in DBF Viewer (just see it) the double values are interpreted incorrectly (positive number bigger than zero are ok)
But for example White Town dbf tools interpret it well.
viliam
|
|
|
|
|
I want to make a small XO game (where you put XO or in my case * and - in order to win you need to have them in a line). For the insertion of a symbol in a place i figured out one way:
using namespace std;
int main() {
char matrix[3][3];
int a,b,choice,i,j;
for( i=1;i<4;i++) {
for(int j=1;j<4;j++) {
matrix[i][j]='0';
}
}
for(i=1;i<4;i++) {
cout<<endl;
for(j=1;j<4;j++) {
cout<<matrix[i][j]<<" ";
}
}
for (int k=1;k<10;k++) {
if ((k % 2) ==0) { cout<<"Choose a field for an '*' :"<<endl;
cin>>choice;
a= (choice / 3) + 1;
b= (choice % 3);
matrix[a][b]='*';
}
else {
cout<<"Choose a field for an '-' :"<<endl;
cin>>choice;
a= (choice / 3) + 1;
b= (choice % 3);
matrix[a][b]='-';
}
for( i=1;i<4;i++) {
cout<<endl;
for(j=1;j<4;j++) {
cout<<matrix[i][j]<<" ";
}
}
cout<<endl;
}
return 0;
}
When i run the program and fill the whole matric with symbols it displays an error :
Runtime check failure #2 : Stack around variable "matrix" was corrupted
Does anyone have a clue what its about>
|
|
|
|
|
Hi
I don't know much about c++, but as far as i know, array indexes in c++ are zero based.
in your code there are several lines where you try to access index 3 of your array which is problematic because it accesses the 4th item. it's not a big problem if you read.
(like here: cout<<matrix[i][j]<<" "; ).
but you're trying to write to some index higher than 3 with this: matrix[a][b]='*'; .
this is because of this line here: a= (choice / 3) + 1; if i enter 9, the result of choice / 3 will be 3 + 1 is 4 which is definitely out of the range of your array.
and i'm not even sure if entering '9' into the console will give you an integer value of 9 or the charcode of '9' which would be 57.
so there are 3 things you should keep in mind by takeing a closer look to your code
1. make sure that you don't access indexes < 0 or > 2
2. check the converting from char to int values. maybe you'll have to use a fuction for this.
3. handle wrong inputs like characters and so on..
greets
m@u
|
|
|
|
|
Hi..Me just a beginner in c++ programming.
I have come acroos a program which is as follows :
I have to prepare a file which contains the information in block format. as an example, the file will look like so:
BEGIN PANELDATA
BEGIN TITLE
Panel Method for Saras Analsis.
Run number 22.
END TITLE
END PANELDATA
this information will be stored in a file. let us call this file SampleInput.dat. our program must scan this information as blocks. we have two blocks in this example. the outermost block has name PANELDATA. this block contain one block named TITLE. title block contains information. in this case the information is stored as multiline text.
consider another example of an input file. let us call this SampleInput2.dat. It may look like so:
BEGIN PANELDATA
BEGIN TITLE
Panel Method for Saras Analsis.
Run number 22.
END TITLE
BEGIN FLIGHTPARAMETERS
3
Mach_number (d) Flight_speed (d) num_Panels (i)
0.8 1.0 2287
END FLIGHTPARAMETERS
END PANELDATA
in this case, the main block, viz., PANELDATA, has two block in it. the FLIGTHPARAMETERS block contains information. the first entry, viz., 3, tells us that there are 3 entries. the next line shows the names and type of those entries. for instance, the name of the first data is Mach_number and its type is double indicated by (d). similarly, num_Panels is the name of the third entry whose type is integer. the next line contains the numerical values. thus, the FLIGHTPARAMETERS block has more extensive structure. The application should first be able to scan through such files, figure out how many blocks are there and what are their types. if the type of a block is TITLE, then we expect multiline text. if the type of block is FLIGHTPARAMETERS, then we expect number of entries, description of entries and the entries themselves. in the same way, more blocks will be added as we go on.
So how to do the coding for this ? Me just clueless..
Pls do help me out...
|
|
|
|
|
I would go for XML and using all it's advantages to perform what you want to do...
There are plenty of examples in the MSDN or in the codeproject itself.
If you want to make it by yourself, then you can always use the serialization methods available (look for serialization in the help system you prefer). you can always make a parser, but again, XML is the way to go to store structured data in an easy way.
Hope this helps...
PS:
Writing VERY URGENT!!! won't get the desired effect here... probably you won't get much answers... after some time navigating the CodeProject you'll see that it is a great community with its own dark side... (specially avoid asking programming questions in the lounge...).
|
|
|
|
|
What is the serialization method u r talkin about ?
can u pls detail me abt it ?
|
|
|
|
|
harish2rock wrote: can u pls detail me abt it ?
Besides the fact that your query is very urgent (which nobody cares about), don't you have a full QWERTY keyboard? Why do you have to TXTSPK here?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
What have you tried to solve the problem, besides posting your entire program requirements on the internet?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Guys,
I did work out on the code and finally came with this output :
#ifndef _SAMPLEINPUT1_
#define _SAMPLEINPUT1_
/**
*File: Sampleinput1.dat
*Description: This file contains the information in block format which is as
BEGIN PANELDATA
BEGIN TITLE
Panel Method for Saras Analsis.
Run number 22.
END TITLE
END PANELDATA
**/
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
int i;
string s1;
ifstream.in("sampleinput1.dat");
if(!in)
{
cerr<<"Unable to open file";
exit(-1);
}
while(in)
{
in.getline(s1,100,'\n');
i=s1.find("BEGIN");
i=s1.find("PANELDATA");
i=s1.find("BEGIN");
i=s1.find("TITLE");
if(i!=string::npos)
{
cout<<"TITLE is a multiline text";
while(!s1.find(END"))
{
cout<<s1;
}
}
i=s1.find("END");
i=s1.find('TITLE");
if(i!=string::npos)
{
cout<<"End of TITLE Block";
}
i=s1.find(END");
i=s1.find("PANELDATA");
if(i!=string::npos)
{
cout<<"End of PANELDATA Block";
}
}
}
in.close();
return 0;
}
#endif
Can u ppl atleast now pls tell me whether it is correct and what modifications are needed for it ?
Also, given the below data in a file,
BEGIN FLIGHTPARAMETERS
3
Mach_number (d) Flight_speed (d) num_Panels (i)
0.8 1.0 2287
END FLIGHTPARAMETERS
How to identify 3 as an integer and (d) or 0.8 as double from the file to the code i have written above ??
Hopefully, u wud help me out guys..
|
|
|
|
|
Pls do help me guys..
isn't there anyone ????
|
|
|
|