|
Hello,
thanks for quick reply, i try as soon as possible!
with best regards
termal
P.S. have a nice weekend!
|
|
|
|
|
Hello,
now i try to solve my problem with cpu usage!
I can't use this clas Win32_Processor, is unknown on my system:
Win32_Processor' : undeclared identifier
what header or libraries to use for this?
Thanks
termal
|
|
|
|
|
termal wrote: I can't use this clas Win32_Processor, is unknown on my system:
Win32_Processor' : undeclared identifier
Code snippet?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi
my problem is that when i boot my computer.Windows xp keep all pins of parallel port high how can i solve this problem.for my project at least pins of data register should be low until i start my program ther is any option of windows registory setting
I will be very greatfull if anybody reply me
thank u in advance
-- modified at 2:09 Saturday 14th July, 2007
|
|
|
|
|
Hi,
you can't solve this problem, this is normal.
Greetings Ralph
|
|
|
|
|
you can make all parallel port pin to low when you start the program.. what the problem in that!
"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
Support CRY- Child Relief And You
|
|
|
|
|
i connect some output device like siron(speaker) they start automatically because window start to give 5 volt at that pin but i want to start when i run my program
|
|
|
|
|
Why not make the siren sound when the pin goes low?
Steve
|
|
|
|
|
Hi,
as all know, we can easily change text of menu items in respective OnUpdate()
function.
But this is (i think) possible for only Menu Items and not for Sub Menus.
I have following menu structure Tools->Application and few sub menu items in this Application menu. How can i know when the 'Application' menu item is going to be drawn or updated, otherwise how can I change text of that Item?
Please help me out...
thanx
|
|
|
|
|
A shure way is to delete the old menu items, and add the new ones.
Greetings from Germany
|
|
|
|
|
tell me is that menu is created dynamically or you getting it from resource file
"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
Support CRY- Child Relief And You
|
|
|
|
|
Hi all,
I have two functions of a class and i want to call these two functions inside many functions which
are derived from other classes.I don;t want to create an object of the class to which the function belongs everywhere.Is there a way out how i can accomplish this.
If making a function static will help:
Regards
|
|
|
|
|
create the class as a member varible of the class to which you call the functions
ClassA has m_classB
ClassB
has the functions your after.
|
|
|
|
|
Yes you can use static functions for that. You can have like a utility class that you can put helper functions in there. Example usage will be like the following code:
//========================
class A{
public:
static void myprint(){
printf("static hello ! \n");
}
};
class B{
public:
void func(){
A::myprint(); // Here you call the static myprint without having to create an object of class A
}
};
int main()
{
B *poB = new B();
poB->func();
A::myprint() // Again, you can call myprint with no object creation
}
//========================
The output of this will be :
static hello!
static hello!
Hope that helps
|
|
|
|
|
However you have to take care of static functions and use these only if you are sure that they fit to your design.
An alternative way to do this is to just derive the classes that needs your functions from the class they belong to. i.e
class A{
public:
void funcA();
void funcB();
};
class B: public A { // inherits class A
// this class now can use the funcA and funcB as its own
};
Its basic OO C++
|
|
|
|
|
nice didn't know that or atleast i forgot about it
more likely i missed it in a lecture due to me
knew that static keeps the varibles and function on the heep (am i correct?)
didnt realise it affected how it could be called?
is that good programming standard or not?
thanks sam
|
|
|
|
|
mmm not exactly. If I remember correctly they are allocated in their own memory space. Cannot remember the name though.. have to look it up.
Regarding whether or not is a good programming standard or not...well...it depends on how to use them.
They should be avoided if another way is possible and good OO techniques should be used instead.
Sometimes they are usefull though and their use might be required.
Of course I wouldn't use static functions all over the place because static functions have their limitations and so they should be used with care.
|
|
|
|
|
Thanks i was needing this answer.
Regards,
Mayank
|
|
|
|
|
Maynka wrote: I don;t want to create an object of the class to which the function belongs everywhere.
You don't need to create objects everywhere, you can accomplish the task with a single instance of the class (the better way to do this is explained by the singleton design pattern).
Maynka wrote: If making a function static will help:
Probably this is the most natural solution, because it seems that you don't need to access instance members in your functions (and, indeed, you cannot access such members in static functions).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi, I am new to Visual C++ programming and this is my first time posting on this forum. I am hoping someone can help me out.
I recently used and modified a class derived from CStatic so that I could have a CStatic box that gives me the ability to color particular words in the box. In order to do this I had to override the OnPaint since it had to change the text color it was painting for those particular words. I was fighting with this for a while to get scrolling to work and I thought I had everything the way I needed it.
My problem is that I realized that with the way I have it set up the user is not allowed to do text selection on the painted text. With my App the user must have the ability to select the text off of the CStatic window so that it can be pasted in another location. How do I make the text selectable?
As I said I am new to Visual C++ programming so don't necessarily assume I have tried anything you may think would be obvious.
Thanks,
Derrick
|
|
|
|
|
the user is not allowed to do text selection on the painted text
I could hardly believe this is the case. The problem might be in redrawing the selected text. IOW, the text selected is not shown as being selected. If so, this is a problem from your drawing algorithm. What are you doing in OnPaint? Are you calling the base class's OnPaint?
--
=====
Arman
|
|
|
|
|
I am not calling the base classes OnPaint. My OnPaint is as follows:
void CStaticColor::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CString staticText = m_delimitedString;
if (staticText != "") {
//Set Font
CFont font;
CFont* pOldFont;
if (font.CreateFont(14, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY,
DEFAULT_PITCH & FF_DONTCARE, "Courier")) {
pOldFont = dc.SelectObject(&font);
}
CRect rect;
GetClientRect(&rect);
//Data Sizing
int newLinePos = 0;
int oldLinePos = 0;
staticTextHeight = 0;
staticTextWidth = 0;
while(newLinePos != -1) {
staticTextHeight += 13;
oldLinePos = newLinePos;
newLinePos = staticText.Find("\r\n",newLinePos + 1);
if ( ( ( newLinePos - oldLinePos ) * 8) > staticTextWidth ) {
staticTextWidth = ( ( newLinePos - oldLinePos ) * 8 );
}
}
//Vertical Scroll Code
if (staticTextHeight > rect.Height()) {
this->EnableScrollBar(SB_VERT, ESB_ENABLE_BOTH);
this->ShowScrollBar(SB_VERT);
SCROLLINFO si = {0};
si.cbSize = sizeof(si); // size of this structure
si.fMask = SIF_RANGE | SIF_PAGE; // parameters to set
si.nMin = 0; // minimum scrolling position
si.nMax = (staticTextHeight); // maximum scrolling position
si.nPage = rect.Height(); // the page size of the scroll box
//si.nPos = 0; // initial position of the scroll box
//si.nTrackPos = 0; // immediate position of a scroll box that the user is dragging
this->SetScrollInfo(SB_VERT, &si, TRUE);
}
else {
ShowScrollBar( SB_VERT, FALSE ); // Hide it
SetScrollPos( SB_VERT, 0 );
}
//Horizontal Scroll Code
if (staticTextWidth > rect.Width()) {
this->EnableScrollBar(SB_HORZ, ESB_ENABLE_BOTH);
this->ShowScrollBar(SB_HORZ);
SCROLLINFO si = {0};
si.cbSize = sizeof(si); // size of this structure
si.fMask = SIF_RANGE | SIF_PAGE; // parameters to set
si.nMin = 0; // minimum scrolling position
si.nMax = (staticTextWidth); // maximum scrolling position
si.nPage = rect.Width(); // the page size of the scroll box
//si.nPos = 0; // initial position of the scroll box
//si.nTrackPos = 0; // immediate position of a scroll box that the user is dragging
this->SetScrollInfo(SB_HORZ, &si, TRUE);
}
else {
ShowScrollBar( SB_HORZ, FALSE ); // Hide it
SetScrollPos( SB_HORZ, 0 );
}
dc.SetBkMode(TRANSPARENT);
CRect outRect(0,0,rect.Width(),rect.Height());
// Create a rect above our target rect that will not allow drawing to.
RECT excluderect;
excluderect.top = outRect.top - GetScrollPos( SB_VERT);
excluderect.bottom = outRect.top;
excluderect.left = outRect.left;
excluderect.right = outRect.right;
dc.ExcludeClipRect(&excluderect);
// Create a rect to the left of our target rect that will not allow drawing to.
RECT excluderect2;
excluderect2.top = outRect.top;
excluderect2.bottom = outRect.bottom;
excluderect2.left = outRect.left - GetScrollPos( SB_HORZ);
excluderect2.right = outRect.left;
dc.ExcludeClipRect(&excluderect2);
//Create a rect to the right of our target rect that will not allow drawing to.
RECT excluderect3;
excluderect3.top = outRect.top;
excluderect3.bottom = outRect.bottom;
excluderect3.left = outRect.right;
excluderect3.right = max(outRect.right, ( outRect.right + (staticTextWidth - outRect.Width()) - GetScrollPos( SB_HORZ) ) );
dc.ExcludeClipRect(&excluderect3);
// Draw the text accounting for any scrolling of the vertical scroll bar.
outRect.top -= GetScrollPos( SB_VERT );
leftRect = outRect.left -= GetScrollPos( SB_HORZ );
outRect.right = max((staticTextWidth +2 - GetScrollPos( SB_HORZ) ), outRect.right);
DrawText(&dc, staticText, &outRect, DT_LEFT | DT_WORDBREAK);
}
// Do not call CStatic::OnPaint() for painting messages
}
Let me know if you need to see my DrawText() or if you have any other questions. I appreciate any help on this.
|
|
|
|
|
This seems awfully complicated for just changing a control's text color. Why not handle the WM_CTLCOLORSTATIC message instead?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I beleive that that message will change the color for all the text in a particular static window. With my program I just want to make certain words within the cstatic a different color. This derived class changes the color by looking for a particular character flag within the text and changing the color until the next flag. I do not want to change the text of the entire cstatic box or this would be a much simpler problem.
Thanks for the comment though. As I said before I can copy the entire string from within the cstatic using shortcut keys but I cannot select portions of the text with the mouse to do a copy. Any ideas on this?
-Derrick
|
|
|
|
|
Derrick Becker wrote: With my program I just want to make certain words within the cstatic a different color.
A richedit control would do this much, much easier.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|