|
I am using the BackColor function, and all the documentation I have seen indicates that you have to let the user choose the color. I am wondering if there is a way to specify which color is used without the user choosing a color?
Thanks
|
|
|
|
|
I'm not sure what "BackColor" function you're referring to or what parameter type it expects, but if it takes a COLORREF, you can make any color with the RGB macro or use any system colors with the GetSysColor() function.
COLORREF clr = RGB(255, 0, 0); // bright red
COLORREF clrWindow = ::GetSysColor(COLOR_WINDOW);
You might also need to use OleTranslateColor, if you're doing COM/OLE_COLOR related stuff.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Tried what you mentioned and it created many more problems that it solved.
The program began acting up and creating many errors with the MessageBox::Show function I am using.
Anyways, on second thought this should have gone in the managed forum but...
I am doing a System::Windows::Forms project, and changing the backcolor with this->BackColor . I have only found ways to let the user selectively change the color, but I would like to specify the color change myself. Do you know of a way to do this?
|
|
|
|
|
Ahh, yeah, the code I mentioned probably wouldn't work in .NET, it's Win32 api.
I think you might need to look up the System::Drawing::Color class and do something like:
BackColor = Color::Red; (or whatever your color choice)
I'm not a .net expert, so hopefully the Color class has a constructor like Color(R, G, B) if you need to do an arbitrary color.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Steve Echols wrote: I think you might need to look up the System::Drawing::Color class and do something like:
BackColor = Color::Red; (or whatever your color choice)
Thanks. That worked.
|
|
|
|
|
Hello
I have a little problem with my app.
I can double click on the assotiated file type (*.app) an the MainFraim of my Prog is started. But to display the information in the file there should also be a ChildFrame opened. And this doesn't happen!
Now how to add this function ?
And/od how to debug this (if Possible)?
THX
|
|
|
|
|
it is ur responsbility to open the file clicked.
check command-line of CWinApp then open a new Doc for the file.
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
hi guyss
I am in a grt problem. when i use installshield to build the setup file of my project, i follow all the steps required properly. after that the setup file is also created but when i install it neither it comes in the "all program". also when i install it in any other computer not having vc++ after installation when i click the exe file to run it gives an error of a missing dll file but i have included this dll file while making the setup. please help as soon as possible as i have to submit the project by a week.
Thanksss
|
|
|
|
|
simanto_iem wrote: I am in a grt problem. when i use installshield to build the setup file of my project, i follow all the steps required properly. after that the setup file is also created but when i install it neither it comes in the "all program". also when i install it in any other computer not having vc++ after installation when i click the exe file to run it gives an error of a missing dll file but i have included this dll file while making the setup. please help as soon as possible as i have to submit the project by a week.Thankss
What exact is teh error Message.. if your Application is build in release mode!, as the debug mode dll may or may not be installed on destination computer
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
Does anyone know of a function that will allow me to distinguish between normal shell items like a text file or a folder & special items like MyComputer, shared documents folder, C drive, CD drive etc. In other words how do I get the attributes of these special folders.
Many thanks.
|
|
|
|
|
Please refer to the shell programing section here in code project:
http://www.codeproject.com/shell/[^]
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
How to make shell extension to monitor appliacation starting? I mean, before application startitng, I need to do something.
Thank you.
|
|
|
|
|
|
I am struggling with an issue. I have a client on who's machine, when a CFrameView derived class comes up, (3 do this) shuts down the app without a message of any kind. The code is now using VC++.net 2003 and the problem surfaced in an older version originally built in VC++ 6
I think I know what is happening. In the base classes if Create returns -1, it puts a message in the message que sutting down the app.
Initially the app started shutting down in a CWin derived splash window due to the same issue, I got that straightened out, but the situation seems to be a bit more pervasive
Does anyone have a clue, what causes -1 to be returned by window creation code?
This app runs fine on many other machines, and has been reliable for quite a while, two of these classes are those that I draw custom on, the other uses the CHTMLView and uses a locally created html file.
Christopher J. Noyes
|
|
|
|
|
Ive got a self made class called Vessel which is a base class for the classes Surface Vessel and Submarine.
The base class holds the data needed for both submarines and surface vessels and then the submarines and surface vessels have thier own data and functions.
Now i have tried to do a linked list where the data in the node is a "Vessel". I can pass a surface vessel or a submarine into this but when i try to get the data back out it loses the inherited class specificities (is that even a word? lol) so i can only access the Vessel data for that particular surface vessel or sub and not the particulars of that class. How can i put a surface vessel or sub into a type "vessel" and get the specific data out again or perhaps change the node data to a sv or sub on the fly?
Cheers
Bill
|
|
|
|
|
Add (pure) virtual functions that return desired information to Vessel, and override them in SurfaceVessel and Submarine.
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
so when i assign a sub to the variable of type Vessel its still holding it as a sub but just cant see the functions / data?
-- modified at 13:31 Sunday 23rd April, 2006
heres the vessel class so how could i impliment the pure functions in them because vessel would have to be totally abstract would it not?
Cheers
#ifndef VESSEL_H
#define VESSEL_H
#include <string>
#include "afxwin.h"
using namespace std;
class Vessel
{
protected:
int _prKey;
int _maxSpeed;
CString _name;
int _length;
int _maxRange;
int _maxDisplacement;
int _crewAmount;
CString _vesselType;
public:
int getKey();
void setKey(int pKey);
int getSpeed();
void setSpeed(int pSpeed);
CString getName();
void setName(CString pName);
int getLength();
void setLength(int pLength);
int getRange();
void setRange(int pRange);
int getDisplacement();
void setDisplacement(int pDisplacement);
int getCrew();
void setCrew(int pCrew);
CString getType();
void setType(CString pType);
};
class SurfaceVessel : public Vessel
{
protected:
int _helicopters;
public:
int getHeli();
void setHeli(int pHeli);
};
class AircraftCarrier : public SurfaceVessel
{
int _aircraft;
public:
int getAircraft();
void setAircraft(int pAircraft);
};
class Destroyer : public SurfaceVessel
{
bool _gunSystem;
bool _guidedMissileSystem;
public:
bool getGunSystem();
bool getGuidedSystem();
void setGunSystem(bool pGunSystem);
void setGuidedSystem(bool pGuidedSystem);
};
class FleetAux : public SurfaceVessel
{
protected:
int _deckSpace;
public:
int getDeckSpace();
void setDeckSpace(int pDeckSpace);
};
class Submarine : public Vessel
{
protected:
int _maxDiveDepth;
int _maxSubmergedSpeed;
int _displacementSubmerged;
public:
int getMaxDiveDepth();
int getSubSpeed();
int getDisplacementSub();
void setMaxDiveDepth(int pMDD);
void setSubSpeed(int pSubSpeed);
void setDisplacementSub(int pDisSub);
};
class SSB : public Submarine
{
int _slbms;
public:
int getSLBMS();
void setSLBMS(int pSLBMS);
};
class SSK : public Submarine
{
int _torpedoes;
public:
int getTorps();
void setTorps(int pTorps);
};
class Tanker : public FleetAux
{
int _storageCapacity; //Litres
public:
int getStorCap();
void setStorCap(int pStorCap);
};
class LandingPlat : public FleetAux
{
int _storageCapacity; // M^3
int _aircraftLand;
public:
int getStorCap();
void setStorCap(int pStorCap);
int getAircraftLand();
void setAircraftLand(int pAirAmount);
};
#endif
-- modified at 13:56 Sunday 23rd April, 2006
|
|
|
|
|
How are you placing the Vessels into the list?
If you are declaring the list to hold whole Vessel types, then that is what is well do. Which means it will only hold the part that represents the base vessel, basicaly slicing off every thing else.
list<Vessel> myList;
You need to store pointers to the base type Vessel in the list. Also remember that you will be responsible for deleting them when they are removed from the list and before the list is destroyed.
list<Vessel*> myList;
INTP
“Testing can show the presence of errors, but not their absence.”
Edsger Dijkstra
|
|
|
|
|
ahh i am basically just passing them in and obviously its being sliced because im only holding the data temporarily when its inputted by the user then it is stored in the nodes Vessel variable. Does this mean that i will have to have make a variable of each type in order to store any type?
Thanks
|
|
|
|
|
William Burton wrote: Does this mean that i will have to have make a variable of each type in order to store any type?
No. A base class pointer can point to any of it's derived class. When mixed with virtual functions you can ensure that the function in the correcct derived class is called even when invoked through a base class pointer.
Steve
|
|
|
|
|
the thing is that in my nodes in my linked list the data is held as a Vessel so if i used a pointer instead of a variable, i would have to declare the variable in the program and not in the class. At the minute im using a temporary variable declared depending on whether a sub or a surface vessel is made and then it assigns the temporary variable to the class variable. If i used a pointer to point to the temporary variable, if i tried to make another of the same type it would overwrite the old temporary variable would it not and therefore the previous node and pointer to the original values in the temporary variable would be worthless?
|
|
|
|
|
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
|
|
|
|