|
use %ld in format function , COLORREF is long int .
regards
krishnan
If u can Dream... U can do it
|
|
|
|
|
How to initialize a variable array in a class? it should be static defined?
class{
...
char array[] = "asdhajsdjasgdj";
...
}
9ine
|
|
|
|
|
9ine wrote: How to initialize a variable array in a class?
Use member initialization list.
But in above case varaible is array, so cant use member initialization list. In constructor body you can initialize(re) it.
class A
{
int i;
char array[1];
public:
A():i(0)
{
array[0]=0;
}
};
9ine wrote: it should be static defined?
Not necessary.
|
|
|
|
|
in C++ (by opposition to C# or java), almost all the members should be initialized in the constructor. the only exception are static members, which init should be done outside of the class definition.
|
|
|
|
|
|
In general, you would initialize member variables as part of the Constructor (either in the implicit parameter list, or in the constructor). For the example you give, you may consider writing it the following way:
class MyClass
{
public:
MyClass() {}
~MyClass() {}
static const char* ms_MyString;
};
const char* MyClass::ms_MyString = "0123456789";
This gives you a single copy of the string regardless of the number of objects of this type you have. It will remain constant (that is, you can't change it), and it will remain in the same location in memory for the entire lifetime of your application.
If you need to have an array that you can change, you would initialize it in the constructor:
class MyClass
{
public:
MyClass() : m_MyString(0) {memset(m_MyOtherString, 0, 100);}
~MyClass() {}
char* m_MyString;
char m_MyOtherString[100];
};
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
The file list view doesnt change on changing the file type using CFileDialog in my applicatio.But in all other cases it works well.What will be the reason for that?
chandana
|
|
|
|
|
Can you post the string you provided as argument for the filter ?
Which OS do you have ?
chands wrote: But in all other cases it works well
What "other cases" do you mean ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
I tried the same code in a sample application,it works well there.
The problem exists in this particular application alone i think.
code:
CString szFilter = "Bitmap Files (*.bmp)|*.bmp|AVI Files(*.AVI)|*.AVI|All Files(*.*)|*.*||";
CFileDialog FileSelect( TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT| OFN_ALLOWMULTISELECT |OFN_EXPLORER , szFilter, NULL );
FileSelect.m_ofn.lpstrTitle = L"FileBrowse";
int nReturn = FileSelect.DoModal();
My Os - Winows XP
chandana
|
|
|
|
|
Whats problem with this code?
|
|
|
|
|
Just tried your code (commented out the title change to FileBrowse because it did not compile), and it works like a charm. It must be another problem. What bugs me is that I already had that problem, but cannot remember what it was...
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Have you supplied some filter's on the file dialog that you are opening?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
How to convert the COLOURREF into the String type.in order to display the selecting colour in the window useing pDC->TextOut();
ramanand
|
|
|
|
|
Use GetRValue(), GetGValue(), GetBValue() functions
-- modified at 6:39 Wednesday 23rd August, 2006
Regard's
Dhana
|
|
|
|
|
<br />
COLORREF color=RGB(255,120,200);<br />
CString Format;<br />
Format.Format("Red=%d, Green=%d, Blue=%d", GetRValue(color),GetGValue(color),GetBValue(color));<br />
|
|
|
|
|
How to find out whether a register key is present in the registry or not?
Thank you.
KIRAN PINJARLA
|
|
|
|
|
Just try opening it with RegOpenKey - this will fail if the key isn't present. If you need to check for a particular value, use RegQueryValueEx which will also fail if the value isn't present.
For more sophisticated applications you can recursively enumerate the registry using RegEnumKeyEx and RegEnumValue, but that shouldn't be necessary if you just want to check a single key.
|
|
|
|
|
Thank you very much matt.
KIRAN PINJARLA
|
|
|
|
|
|
Hi,
I have an MDI application with splitterwindows under VS 6.0 (one documenttype, but you can open different documents) . One splitter is fix, like an outlook bar and one will be replaced. When I click on Menue (load document) then my programm reads a specific file and open many other files and handle them.
Now I want to do something like this. In one view I insert a list of names and when I click on a button I want to split the list into groups and display them in differnet childframes. I also want the behaviour of that every childframe works in his own folder. When I click on the menue and do it manually it works. When I do it with my button, the childframes will be created correctly but when the files will be saved, they are all in the same folder.
When I click on the menue a function in the ProjectApp.cpp do the work. When I call this function from the view with theApp.Function() it works like I discribed. So my Idea is to send a Message from the view to the App, but it doesn't arrived. I tried it with GetParent() and AfxGetMainWnd()but nothing works.
Is here someone who has an idea how to solve my problem?
Thanks for help
yummi
PS: Sorry for my english but I hope you can understand what I mean.
|
|
|
|
|
Hello..
I need a function to windows like gettimeofday in linux.
Can you help me?
|
|
|
|
|
|
it was a possibility, but i want to get time in microseconds, and this functions only give me the time in miliseconds. Is there any function which return the microseconds?
thanks
|
|
|
|
|
You can get more bits by using GetSystemTimeAsFileTime and working with the result, which is in 100ns intervals.
However, you won't get any better results, because the system clock is only updated as often as the clock timer ticks, which on most Windows systems is approximately 15ms. To see what yours is, run ClockRes[^]. I'm sure this is true of Linux as well.
The system doesn't necessarily add 15ms every time the system timer ticks, it may add a slightly larger or smaller amount to allow for clock drift.
|
|
|
|
|
If you really need more accuracy then you'll need to use the QueryPerformanceCounter API: HighResolutionElapsedTimer and MS's KnowledgeBase has more details on this. It's not an actual 'time of day' though; just a high resolution timer you can use to time. If you need both time of day and very high precision timings, you'll need to combine the two methods (or even use an external hardware peripheral like a GPS receiver!)
|
|
|
|