|
|
LPCSTR means :
LP for Long pointer ('cause pointers are 4-bytes long)
C for Constant
STR for String
so, if you like GetWindowwDirectory() to write into your variable, it musn't be constant....
understand ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
wow very nice explanation thank you
very helpful
|
|
|
|
|
Hi all,
I want to run a program like NetworkSetupWizard. It Takes 1 minute in my computer, 0.5 minute in my friend's and so on.
How can my app finds out when the work finishes?
Please help me,
Best Regards,
Thanks.
|
|
|
|
|
If your intention is to run a new process and get notification when it stops, here is a good article :Link[^]
suhredayan There is no spoon.
|
|
|
|
|
What is your problem?
Do you want to get the time that program takes until it exits or completes an operation?
Don't try it, just do it!
|
|
|
|
|
Yes,
Exactly,
Please tell me if you know,
Cheers,
Thanks.
|
|
|
|
|
below is my code the whole program is for prompting user to enter 10 nos. b/w 20 to 100 while is there to check wheter the user entr the corect number or not, it will also check that the entered number is unique and was not previously entered by the user. at end of program simply it will display the non dublicate nos. whole program is correct and output is also correct but this program is taking integers in place of dublicate numbers. suppose the user enter 50, 60, 70, 89, 56, 200, 47, 50, 56, 95 and 21 here 56 and 50 are dublicate values my program is taking 2 values in place of them. what should i do as i don't want any other value in place of dublicate values. i simply want to display values (from abve example) 50, 60, 70, 89, 56, 47, 95, 21.
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
int nTmp,i,j;
bool bFlag=false;
int a[10];
cout<<"entr 10 numbers b/w 20 and 100"<<endl;
="" for(i="0;i<10;i++)" {="" while(!bflag)
="" cout<<"enter="" value"<<endl;
="" cin="">>nTmp;
////Here we check first Condition
// no between 20 and 100
while((nTmp<20)||(nTmp>100))
{
cout<<"enter no b/w 20 and 100"<<endl;
="" cin="">>nTmp;
}
for(j=0;j<i;j++)
="" {
="" for="" checking="" whether="" the="" value="" is="" dublicate="" or="" not="" if(a[j]="=nTmp)" break;
="" }
="" }="" if(j="=i)" {="" save="" variable="" a[i]="nTmp;" bflag="true;
" again="" make="" it="" false
="" display="" non="" numbers.
="" cout<<"="" nos="" are="" "<<endl;
="" for(j="0;j<10;j++)" cout<<a[j]<<endl;
="" getch();
}="" <="" b="">
Rose
|
|
|
|
|
That is exactly the kind of a question I dislike.
Didn't you post the same questions some days ago?
Don't try it, just do it!
|
|
|
|
|
This slight modification to your code will get you closer to your end result:
void main( void )
{
int i,
j,
nNumber,
a[10] = {0};
for (i = 0; i < 10; i++)
{
do
{
cout << "Enter a number between 20 and 100: ";
cin >> nNumber;
} while (nNumber < 20 || nNumber > 100);
for (j = 0; j < i; j++)
{
if (a[j] == nNumber || a[j] == 0)
break;
}
if (a[j] == 0)
a[j] = nNumber;
}
cout << "The non-duplicate numbers:" << endl;
for (j = 0; a[j] != 0; j++)
cout << a[j] << endl;
getch();
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have derived a class from CButton , named CMyButton , when i add function(for exmple)
void CMyButton::SetButtonText(CString text)
{
this->SetWindowText("");
}
//and then call
CMyButton b;
b.SetButtonText("test");
//it compiles succesfuly
but then i get debug assertion failed, and in debug i get "invalid window handle", i know the problem is in
this->SetWindowText("");
can anyone tell me what i have write instead of "this->",to avoid this problem??
Regards
m0n0
|
|
|
|
|
You never created the window for the button. See CButton::Create in the help.
John
|
|
|
|
|
Look John, it's my mistake i had to be more clear in my thread ,
i have alerady created a button using simple toolbox and added a variable to it , then in my ***Dlg.h file i have renamed it like this
//before
CButton b;
//after
CMyButton b;
so the button is already created, i have problem with
"this->" i think it is not correct the way i use it
Regards
m0n0
|
|
|
|
|
It is not the proper way to use it as I would never do that but there is nothing wrong with this-> asside from the fact that it is reduntant.
The proper way is to remove the this-> and just call the member function. But this is not your problem.
Again your problem is the button was never created. This is a windows thing and not c++. Every control must have a window created for the control itself and in most casess a window (or dialog box) created to place the control on.
John
|
|
|
|
|
You are being plagued by recursion (which you would have seen had you set a breakpoint on the this->SetWindowText("") statement). Change your code to:
void CMyButton::SetWindowText( CString strText )
{
CButton::SetWindowText("");
} and it'll work fine.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
His original code was:
void CMyButton::SetButtonText(CString text)
{
this->SetWindowText("");
}
I am not sure how this can recurse?
It was probably because he did not set it to a 'real' button window before trying to set the text.
One way to check:
void CMyButton::SetButtonText(CString text)
{
if( ::IsWindow(this->m_hWnd) ){
this->SetWindowText("");
} else {
// Gadzooks! No window is assigned yet! Set status to DefCon IV!
}
}
|
|
|
|
|
Blake Miller wrote:
I am not sure how this can recurse?
Did you not try it out? It can, and does, recurse. Why would it not? The call to this->SetWindowText("") matches the prototype of void CMyButton::SetButtonText(CString text) . This is all due to CString 's LPCSTR operator.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hello David;
I just tried it out. No recursion occurred whatsoever.
SetButtonText does not get called by SetWindowText. The functions have similar signature, but different name. And that is why I originally did not beleive they would recurse, by inspection, but now I demonstrated to myself they do not recurse - by definitive testing.
I noticed that there was a runtime assertion on a window handle WinOcc.cpp - line 229 - ASSERT(::IsWindow(m_hWnd)); , but once I did SubclassDlgItem on an existing button control it works as expected. I maintain you can not SetWindowText on a CButton or CButton-derived class until the class has been assigned to an existing button window.
This is code path I observed:
CMyButton::SetButtonText -> CButton::SetWindowText -> ::SetWindowText
If you can get it to recurse, please explain exactly how.
|
|
|
|
|
Ok, I totally messed up. I thought both were SetWindowText() . I should've read just a tad closer. No wonder my comment to you and Giorgi sounded weird.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi,
The codes below are used to create button and activate some function, when I compile it, it shows some error message as below.
could some of you tell me how to solve it!
Thanks!
RunButton ( HWND hwnd )
{
CreateWindow(
"BUTTON",
"Run",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
380,
40,
60,
25,
hwnd,
NULL,
(HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
NULL);
return 1;
}
.
.
.
case WM_COMMAND:
switch HIWORD(wParam)
{
case BN_CLICKED:
switch (lParam)
{
case RunButton: <--- error C2051: case expression not constant
CetCapConnect( hwnd );
break;
} <--- warning C4060: switch statement contains no 'case' or 'default' labels
break;
|
|
|
|
|
Francis Chau wrote:
RunButton ( HWND hwnd )
{
CreateWindow(
"BUTTON",
"Run",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // styles
380,
40,
60,
25,
hwnd,
NULL,
This last NULL should be the ID of your button. This will be the value passed in the loword of the wparam parameter in the BN_CLICKED notification.
Francis Chau wrote:
case WM_COMMAND:
switch HIWORD(wParam)
{
case BN_CLICKED:
switch (lParam)
{
case RunButton:
The lParam parameter contains the HWND of your button, which is the return value of the CreateWindow() function. Also the case expression has to be a constant value, the compiler has to know what the value is when it compiles the code, it can not be a value that is generated when the code is run. If you want to switch on a variable then you have to use the if...else if construct.
This is how I would do it, but I would also add some error checking to make sure that CreateWindow() actually was able to create the button.
#define ID_RUNBUTTON 1001
.
.
.
RunButton ( HWND hwnd )
{
CreateWindow(
"BUTTON",
"Run",
WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
380,
40,
60,
25,
hwnd,
ID_RUNBUTTON,
(HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
NULL);
return 1;
}
.
.
.
case WM_COMMAND:
switch HIWORD(wParam)
{
case BN_CLICKED:
switch (LOWORD(wParam))
{
case ID_RUNBUTTON:
CetCapConnect( hwnd );
break;
}
break;
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
|
hi,
im using EnumPrinters to detect local printers on win2k. however this returns all printer devices found on the system, incl. for example also "Microsoft Office Document Image Writer" or "Adobe PDF Writer". How to programatically found out which of the detected handles is for a 'real' hardware printer?
thanx
|
|
|
|
|
I think you can't.
Don't try it, just do it!
|
|
|
|
|
nice
hm... any other way getting this info ? through the printer handle from OpenPrinter ?
|
|
|
|
|