|
Can you show the code with this "temporary variable"?
Steve
|
|
|
|
|
if(_addtodb.DoModal() == IDOK)
{
UpdateData(true); // Retrieve Current Values
_addtodb._comboContent.MakeUpper();
if (_addtodb._comboContent == "SSB SUBMARINE")
{
SSB temp;
temp.setType("SSB Submarine");
temp.setKey(list.getNodeAmount());
temp.setName(_addtodb._vesselName);
temp.setSpeed(_addtodb._vesselMaxSpeed);
temp.setLength(_addtodb._vesselLength);
temp.setRange(_addtodb._vesselMaxRange);
temp.setDisplacement(_addtodb._vesselMaxDisplacement);
temp.setCrew(_addtodb._vesselCrew);
temp.setMaxDiveDepth(_addtodb._vesselMaxDiveDepth);
temp.setSubSpeed(_addtodb._vesselMaxSpeedSubmerged);
temp.setDisplacementSub(_addtodb._vesselDisplacementSubmerged);
temp.setSLBMS(_addtodb._vesselSLBMS);
list.addNode(&temp);
}
else if (_addtodb._comboContent == "SSK SUBMARINE")
{
SSK temp;
temp.setType("SSK Submarine");
temp.setKey(list.getNodeAmount());
temp.setName(_addtodb._vesselName);
temp.setSpeed(_addtodb._vesselMaxSpeed);
temp.setLength(_addtodb._vesselLength);
temp.setRange(_addtodb._vesselMaxRange);
temp.setDisplacement(_addtodb._vesselMaxDisplacement);
temp.setCrew(_addtodb._vesselCrew);
temp.setMaxDiveDepth(_addtodb._vesselMaxDiveDepth);
temp.setSubSpeed(_addtodb._vesselMaxSpeedSubmerged);
temp.setDisplacementSub(_addtodb._vesselDisplacementSubmerged);
temp.setTorps(_addtodb._vesselTopedoes);
list.addNode(&temp);
}
as a small example from my main prog, there are more elseifs too for other types chosen
|
|
|
|
|
I can see a number of problems here. One of them is the following usage pattern:
{
SSK temp;
list.addNode(&temp);
}
To fix this problem use code like this:
SSK pTemp = new SSK;
list.addNode(pTemp);
Now the pointer in "list" doesn't outlive the object it points to (when it does the pointer is known as a "dangling pointer").
You have to remember to delete the object you new ed when you no longer need it: with new you manage the lifetime of the object explicitly. For example to empty "list" and delete all the objects it contained you can use code like this:
template <typename T>
struct Delete_Object
{
bool operator()(T *pObj) const
{
delete pObj;
return true;
}
};
for_each(list.begin(), list.end(), Delete_Object<Vessel>());
list.clear();
Finally because we're calling delete on the base class but the actual object is of a derived type the descructor has to be virtual:
class Vessel
{
public:
virtual ~Vessel()
{
}
};
Steve
|
|
|
|
|
John R. Shaw wrote: “Testing can show the presence of errors, but not their absence.”
Edsger Dijkstra
For what its worth, Dijkstra's quote is actually:
"Program testing can be used to show the presence of bugs, but never to show their absence."
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Thanks David, I knew I should have checked.
The quote came from one of my new class mates who insured me that it was accurate and that I did not need to verify the source, since he wrote a paper on the author.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
As Ronald Reagan once said, "Trust but verify."
Back when I was in college, Prof. Dijkstra came and gave a colloquium. It was intense, but I do remember him having a slight bit of humor, too.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
Hi, I have a quick question on the printing:
I have a VC++ 6.0 application that prints labels on the label paper. In my printer (Canon i550), it prints properly within the dimension of the label. The way I print from the application is that I use GetPrinterDC() and attach it to CDC and then do TextOut to print at certain location.
It prints correctly on my printer however when I tried to print on a different printer (Epson), the font became slightly bigger and the contents go out of the specified label area.
What do I do to fix this issue?
Here is the code that print:
CDC dc;
dc.Attach(printdlog.GetPrinterDC());
DOCINFO docinfo;
memset(&docinfo,0,sizeof(docinfo));
docinfo.cbSize = sizeof(DOCINFO);
docinfo.lpszDocName = "Labels"; // document name for the spooler
CFont f;
f.CreateFont(54,0,0,0,100,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,"Arial");
dc.SelectObject(f);
if (dc.StartDoc(&docinfo) > 0)
{
dc.StartPage();
dc.SetMapMode(MM_TEXT);
dc.TextOut(i_Width-120, i_Height, m_Tit);
.
.
.
Thanks for your help,
JK
|
|
|
|
|
You can use GetTextExtent to see how 'wide' your text will be. If it is too wide for the label, then recreate the font with a smaller height so that it will fit on the label.
You are merely being subjected to the different interpretations of the fonts within the different printers.
People that start writing code immediately are programmers (or hackers), people that ask questions first are Software Engineers - Graham Shanks
|
|
|
|
|
Hi,
i want to extract a zip file for which i used ShellExecute()
from my VC++ program. since it is a password protected zip file i had to pass that password too to that function.but when i do that i got the error as
Winzip parameter validation error.
the code i used is
ShellExecute(NULL, "open", "winzip.exe", "-e -s"+bcs+" E:\\bcs.zip","C:\\extract\\here", SW_SHOWNORMAL);
where bcs is my password.
im not sure whether ShellExecute() is the appropriate fn for this.if anyone can suggest another method, please help me
lekshmi
|
|
|
|
|
|
hi
i just want to pass it thru the ShellExecute().
or is there any other methods by which i can do that?
lekshmi
|
|
|
|
|
you build a command line as described in the page i've sent you, and pass it to shell execute...
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
hi
thank you for the sudden reply
i am new to VC++.can you give me a mall example to build a command line.
thanks in advance.
|
|
|
|
|
it has nothing to do with vc++....
look at what you wrote :
ShellExecute(NULL, "open", "winzip.exe", "-e -s"+bcs+" E:\\bcs.zip","C:\\extract\\here", SW_SHOWNORMAL);
You already gave a command line ("-e -s"+bcs+" E:\\bcs.zip") just add the proper password command line ....
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Open a command line box and do it manually then use that for your ShellExecute values.
It might be worth copying the command line to a window so you know that you have generated the correct comand line.
Elaine
The tigress is here
-- modified at 12:06 Sunday 23rd April, 2006
|
|
|
|
|
lekshmipriya wrote: ShellExecute(NULL, "open", "winzip.exe", "-e -s"+bcs+" E:\\bcs.zip","C:\\extract\\here", SW_SHOWNORMAL);
Shouldn't -e be one of -ex, -en, -ef, -es, or -e0?
Is bcs the actual password, or is it a variable containing the password?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
In my Application inform "Dialog", i use a listbox.
In the ListBox's properties window,i use:
Border:(checked)
Notify:(checked)
Horizontal scroll:(checked)
Vertical scroll:(checked)
No integral heigh:(checked)
Selection: single
Onwner draw: Fixed
Has Tring:(checked)
But when i run my program ,it has error:
"MyApplication MFC Application has encountered a problem and needs to close. We are sorry for the inconvenience."
if i chose : Onwner draw: No
then no error!
Could you help me ?
Lgx
|
|
|
|
|
Although this settings doesn't crash my tested application....
Maybe you should concider this:
Owner draw
Controls the owner-draw characteristics of the list box. Possible values are as follows:
· No (default): Turns off the owner-draw style. The list box contains strings.
· Fixed: Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are the same height.
CWnd::OnMeasureItem is called when the list box is created and CWnd::OnDrawItem is called when a visual aspect of the list box has changed.
· Variable: Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height.
CWnd::OnMeasureItem is called for each item in the list when the list box is created and CWnd::OnDrawItem is called when a visual aspect of the list box has changed.
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
|
Hi,everyone!I want to write a program about bitmap transparency.Although I know the API function TransparentBlt(),I need an half-transparency function.How should I do?Thank you!
|
|
|
|
|
Use the AlphaBlend API method, check out MSDN ....
hope this helps
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi ,
Iam using the following code to load an icon
HICON hIconImage;<br />
hIconImage = (HICON)LoadImage(NULL, MAKEINTRESOURCE (IDR_ICON ), IMAGE_ICON, ICON_SIZE, ICON_SIZE, LR_LOADTRANSPARENT|LR_CREATEDIBSECTION );
But hIconImage is NULL after the loading.
Regards,
FarPointer
|
|
|
|
|
Your first parameter of the LoadImage is
(Taken from MSDN "hinst
[in] Handle to an instance of the module that contains the image to be loaded. To load an OEM image, set this parameter to zero."
so why do you use NULL? use something like AfxGetInstanceHandle()....
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
if icon is in resoruce use
LoadIcon(AfxGetApp()->m_hInstance,name icon);
|
|
|
|
|
Hey folks:
If you only want to have one instance of your .exe running, how can you detect that it is already running, and then exit gracefully?
(MFC is OK, but no .NET please), and I'm a noobster so please keep that in mind when answering :P
|
|
|
|