|
Why Can't you ask your teacher or teacher's assistant ?
it's vague, don't you have a real description for YOUR homework ? a set of criteria, instructions, course-ware, books, classes notes ?
don't want to sound rude, but your not giving us much ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
An interface is something that makes one thing interact with another. For instance a Human Machine Interface handles the Human interaction with the machine. Is your project suppose to handle the interaction between t
|
|
|
|
|
I'm trying to print an image to an area with certain dimensions in GDI+. First I construct a graphics object:
Graphics graphics(dc.m_hDC);
Then I load the image and print it:
graphics.DrawImage(pImage, rfDraw, rfPic.X, rfPic.Y, rfPic.Width, rfPic.Height, UnitPixel);
The rfPic rectangle is the source area to draw from, containing e.g. (0, 0, 1000, 800), the entire 1000 x 800 pixel image (I need to have the possibility to draw a portion of the image). The rfDraw rectangle is the destination area to draw to, containing e.g. (100, 100, 6100, 4900).
The printer has a 600 x 600 dpi resolution. Thus the printed image should be:
(6100 - 100) pixels / 600 dpi = 10 inches wide, and:
(4900 - 100) pixels / 600 dpi = 8 inches high.
However, the image is blown up to gigantic proportions. Can someone tell me why?
With smaller values in rfDraw , it works as expected when drawing to screen (which is 'just another device', but with 96 dpi). Also, similar code worked perfectly in GDI (without the +), using IPicture . I ported the code to GDI+, to be able to rotate and more.
I tried: using other unit values, like UnitDocument ; setting the page scale and units to different values; checking the device resolution (indeed 600 dpi in both directions).
This is costing me a lot of paper and printer cartridges! Please help!
Thanks in advance!
|
|
|
|
|
Hi ..
Is there anyway.. to get the icon for the given file name? in c++?
I tried to convert following vb code to c++ using VS.Net. but I got errors
<br />
Function GetIconLocation(ByVal filename As String, ByVal index As Integer) As String<br />
Dim loc As String<br />
'Use this to get the small icon.<br />
Dim shinfo As SHFILEINFO<br />
shinfo = New SHFILEINFO<br />
Dim hImgSmall As IntPtr 'The handle to the system image list.<br />
<br />
hImgSmall = SHGetFileInfo("c:\" & filename, 0, shinfo, Marshal.SizeOf(shinfo), SHGFI_ICON Or SHGFI_LARGEICON)<br />
Dim hIcon As Icon<br />
'hIcon = hIcon.FromHandle(hImgSmall)<br />
hIcon = Icon.FromHandle(shinfo.hIcon)<br />
Dim bip As System.Drawing.Bitmap<br />
bip = hIcon.ToBitmap()<br />
loc = "c:\icon" & index.ToString & ".png"<br />
bip.Save(loc)<br />
loc = "<img src=""" & loc & """><br><font size=""-2"" face=""Times"">" & filename & "</font>"<br />
shinfo = Nothing<br />
Dim f As File<br />
f.Delete("c:\" & filename) ' delete the file<br />
GetIconLocation = loc
end Function
I tried to used
<br />
#using <mscorlib.dll><br />
#using <System.dll><br />
using namespace System;<br />
using namespace System::IntPtr;<br />
I dont' know how to use those namespace System classes from regular c++ in Visual Studio .Net.
Can anyone help me please?
Thank you.
but
|
|
|
|
|
pnpfriend wrote:
Is there anyway.. to get the icon for the given file name?
ExtractIcon() comes to mind.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I am drawing a newbie blank here. Can someone show me how to read 20 bytes from the serial port using this code:
BOOL CSerialPort::ReadByte(BYTE &resp)
{
BYTE rx;
resp=0;
DWORD dwBytesTransferred=0;
if (ReadFile (hComm, &rx, 1, &dwBytesTransferred, 0))
{
if (dwBytesTransferred == 1)
{
resp=rx;
return true;
}
}
return false;
}
Thanks
|
|
|
|
|
I think you can solve this problem by the following code:
BYTE byte2Read[20];
for( int nRead=0; nRead<20;)
{
if( ReadByte( byte2Read[nRead] ) )
{
nRead++;
}
}
Coding,I love it! MM,I Love it 2!!
|
|
|
|
|
Can someone tell me why this isn't freeing up the memory like it suppose to?
Thanks
#include <afxwin.h>
#include <iostream.h>
class CDeeper : public CObject{
private:
CString *strTemp;
public:
CDeeper():strTemp(new CString){}
~CDeeper(){}
void setStr(CString setTemp){ *strTemp = setTemp; }
void Delete(){ delete strTemp; strTemp = NULL; }
};
class CTest : public CDeeper{
private:
int num;
CObList DeeperList;
CDeeper *pDeeper;
public:
CTest(){}
~CTest(){}
void setStr(int i){
num = i;
pDeeper = new CDeeper;
pDeeper->setStr("Hello");
DeeperList.AddTail(pDeeper);
}
void Delete(){
POSITION pos;
pos = DeeperList.GetHeadPosition();
while(pos){
pDeeper = (CTest *)DeeperList.GetNext(pos);
pDeeper->Delete();
delete pDeeper;
}
DeeperList.RemoveAll();
}
};
int main(){
POSITION pos;
CObList strList;
CTest *pTest;
int i;
for (i=0; i< 50000; i++){
pTest = new CTest;
pTest->setStr(i);
strList.AddTail(pTest);
}
pos = strList.GetHeadPosition();
while(pos){
pTest = (CTest *)strList.GetNext(pos);
pTest->Delete();
delete pTest;
}
strList.RemoveAll();
return 0;
}
|
|
|
|
|
Change CDeeper to:
class CDeeper : public CObject
{
private:
CString *strTemp;
public:
CDeeper(){}
~CDeeper(){}
void setStr(CString setTemp){ strTemp = new CString(setTemp); }
void Delete(){ delete strTemp; strTemp = NULL; }
};
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I found out I can do
class CDeeper : public CObject{
private:
CString *strTemp;
public:
CDeeper():strTemp(new CString){}
~CDeeper(){ delete strTemp; strTemp = NULL; }
void setStr(CString setTemp){ *strTemp = setTemp; }
void Delete(){ }
};
Now I need to figure out why the three cases are different
|
|
|
|
|
One additional question on this. I notice when I call delete pTest it calls the destructor again and strTemp at that point is pointing to an unknown location with no value.
Anyway to prevent that?
|
|
|
|
|
Hi this is my first time using MFC and I just created a basic MFC aplication where you can enter data and display a calculated result (dialogue based). However I need to incorporate some file input and output which i wrote using a win32 console application <fstream>. Is there an easy way to allow MFC to recongise <fstream> because atm its having none of it?
|
|
|
|
|
When CHtmlView completes loading document it steals focus. How to avoid this?
|
|
|
|
|
I have a program with an active x control. Before I can run the program properly, I need to locate the .ocx file, and then register the control. Just what is an ocx file? What does registering the active x control do?
Thanks.
Jerry
|
|
|
|
|
An OCX is simply a DLL with a different extension, nothing more, nothing less. If it supports self-regisration (and almost all do), it will export a function called DllRegisterServer. The writer of the OCX puts whatever functionality is necessary to register the OCX correctly in this function. This is typically just adding some registry keys.
Note that an OCX does not *have* to export a DllRegisterServer function - you could just list the registry entries needed for correct operation in a text document shipped with the OCX - but every commercial OCX I've ever come across does.
To register the OCX, load it using LoadLibrary , get a pointer to the DllRegisterServer function using GetProcAddress , and then call the function itself. DllRegisterServer is a void function that takes no parameters.
|
|
|
|
|
I have some problems with a c++ file containing about 7000 lines. Sometimes, Visual Studio copies some of the last lines of the file, and prints them at the bottom of the file... only problem is that it doesn't show them in the editor.. I have to reopen the file to find and delete the 'new' code.. anyone having the same problem??
I am using Visual Studio .NET 2003..
øivind
|
|
|
|
|
I think your problem is, that you have a file containing 7000 lines
You should find a way to split it.
I often find duplicate code in such code fragment -> make them functions.
If it is a Class.cpp it is probably the class is too big, tries to cover too much. Extract Classes from it.
HTH
Kind regards
Sawatzky
PS: No I never had that problem
|
|
|
|
|
I think I've read others complaining about that bug. Try searching the lounge.
Todd Smith
|
|
|
|
|
I have a dialog, which have a CEdit control inside. How can I let Dialog catches ( intercept ) the CEdit's keyboard input. I mean, I want dialog OnChar() be called, when user type in CEdit box.
Thanks ;P
|
|
|
|
|
Have you tried deriving a class from CEdit ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Would you give me a explicit anwser?
|
|
|
|
|
Use ClassWizard (Ctrl+W) to open the New Class dialog, type a name for the new class and select CEdit from the Base class combobox.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
What's the equivenlent of ATL::CContainedWindow and ALT_MSG_MAP in MFC?
I'm after the IE "Shell Embedding" window from a CHtmlView.
Todd Smith
|
|
|
|
|
Hi,
i need to run a program from my VC++ app. In Delphi there was an "ExecuteFile" , can someone help me with the equivalent from VC++ ?
|
|
|
|
|
Try CreateProcess() or ShellExecute() .
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|