|
In additional you can use GetSaveFileName or GetOpenFileName
|
|
|
|
|
|
Bagaturia david wrote: char *Get(void)
{
static char a[]="thanks for any help!!!!";
char *p;
p = a;
return p;
}
p is a local variable even though it points to static buffer so it gets destroyed as soon as the function exists. This kind of coding should be avoided.
char *Get(void)
{
static char szString[] ="thanks for any help!!!!";
return szString;
} The same applies for long too.
|
|
|
|
|
The first case seems to work fine: it displays the entire string in our tests. What do you mean by "I get only one element and not array"?
In the second case the "<<" operator has a special meaning for your pointer: it display the address stored in the pointer, i.e. the address of your array. In order to display the pointed value (actually the first element from the array), try this:
cout << *p;
In order to display all of values, I think you need a loop.
-- modified at 6:14 Tuesday 14th November, 2006
|
|
|
|
|
Hi.
I want to do a small MFC application with a green background. I've seen in codeproject one quick way is to change OnEraseBkgnd() to:
BOOL CTestDlg::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBrush brTapete(RGB(0,127,0));
pDC=this->GetDC();
CBrush* pBrush = (CBrush*)pDC->SelectObject(&brTapete);
CRect Recto;
pDC->GetClipBox(Recto);
pDC->PatBlt(Recto.left,Recto.top,Recto.Width(),Recto.Height(),PATCOPY);
pDC->SelectObject(pBrush);
return TRUE;
}
It works, but now I have problems when putting controls like static texts on it. Their backgrounds are not the same as the application, so it's quite ugly. I've tried to change the control's property "Transparent" to True, but it doesn't work. I guess it's a problem in OnEraseBkgnd not redrawing the background behind the control, but I don't know what to do.
Someone can give me any orientation?
Thanks!
Rad.
|
|
|
|
|
You need to handle WM_CTLCOLOR message for static control.
Set background mode as TRANSPERANT there.
|
|
|
|
|
That was the problem! Now it works perfectly. Thanks, prasad_som!
Rad.
|
|
|
|
|
It seems you find your answer but also see another messages WM_CTLCOLOR* for EDIT,STATIC,LISTBOX and...
|
|
|
|
|
One file is created. I want to set the file attribute as "READ ONLY" from VC++ coding. when file is in read only mode it can not write data. Right click on created file and uncheck the "Read Only" property of file, this file property change information ahould get notified in VC++ code.
After unchecking the file property, it is able to write data into created file.
How to set file permission/property in VC++? and how to get the notification of file property into VC++?
Enjoy Life........
|
|
|
|
|
Poonamol wrote: One file is created. I want to set the file attribute as "READ ONLY" from VC++ coding
SetFileAttributes[^].
Poonamol wrote: and how to get the notification of file property into VC++?
Dont know about this, if it is possible .
|
|
|
|
|
Hello,
Thanks for instant reply,
But still I am facing problrms while removing read only attribute from file properties, this file is not opened for writting data.
Using GetFileAttribute[^] is it possible to get the notification of file properties whether it is read only / write?
Enjoy Life........
|
|
|
|
|
Poonamol wrote: But still I am facing problrms while removing read only attribute from file properties
Can you show code ? you are using.
I'm sure this should work,
SetFileAttributes("filename",FILE_ATTRIBUTE_NORMAL);
See this[^] example for more info.
Poonamol wrote: this file is not opened for writting data.
You need to mention this while opening file.
Poonamol wrote: Using GetFileAttribute[^] is it possible to get the notification of file properties whether it is read only / write?
You can determine whether this file is readonly by using this API.
BTW, why you are mentining 'notifications" here ? Notification are different from what you had mentioned here.
|
|
|
|
|
Can you show how do you use of SetFileAttribute
|
|
|
|
|
This may be a naive answer, but you could use CreateFile() and set to read only access, then close the HANDLE to the file, and then reopen the file using CreateFile() and set the attributes to what ever you need them to be.
That might be a lot of opening and closing though.
I win because I have the most fun in life...
|
|
|
|
|
Hi,
I am using following operations on file.
std::ofstream _logss;
const char * _filename = "xxx.out";
ofstream _logss(_filename,ios::out|ios::trunc);
file.open(_filename,ios::in);
Here I can not use CreateFile().
Please do needful.........
Enjoy Life........
|
|
|
|
|
Hi,
I am using following operations on file.
std::ofstream _logss;
const char * _filename = "xxx.out";
ofstream _logss(_filename,ios::out|ios::trunc);
file.open(_filename,ios::in);
Here I can not use CreateFile().
Please do needful.........
Enjoy Life........
|
|
|
|
|
Hi,
I am using following operations on file.
std::ofstream _logss;
const char * _filename = "xxx.out";
ofstream _logss(_filename,ios::out|ios::trunc);
_logss.open(_filename,ios::out|ios::app);
file.open(_filename,ios::in);
Here I can not use CreateFile().
Please do needful.........
Enjoy Life........
|
|
|
|
|
<br />
SetFileAttributes("d:\\123.txt",FILE_ATTRIBUTE_READONLY);<br />
SetFileAttributes("d:\\123.txt",FILE_ATTRIBUTE_NORMAL);<br />
|
|
|
|
|
Hey,
Here is the code
const char * _filename = "xxxx.out";
std::ofstream _logss;
SetFileAttributes(_filename, FILE_ATTRIBUTE_READONLY);
if(GetFileAttributes(_filename) != FILE_ATTRIBUTE_READONLY)
{
.....
.....
if(_size >MAX_FILE_SIZE )
{
.....
ofstream _logss(_filename,ios::out|ios::trunc);
.....
}
.....
.....
}
Is there any problem in above code?
Enjoy Life........
|
|
|
|
|
Your code is right,what problems?
|
|
|
|
|
I looked up MSDN and found the API function'SetConsoleWindowInfo ' ,which can resize,according to MSDN, the size and position of a console window, however,I tried it and found it doesn't work at all.I don't understand why the API doesn't work on my PC(IDE: VC++ 6.0 OS:WinXP SP2)
Some books says the API function,SetWindowPos,can changes Z order of a child, pop-up, or top-level window.I want to set the console window as the topmost window,so I use the API function ,but I don't know how to get the handle of a console window,I tried to get a console handle by the sentence, ConsoleHnd = GetStdHandle(STD_OUTPUT_HANDLE);
Unfortunately,I got the following error message:
error: argument of type "HANDLE" is incompatible with parameter of type "HWND".
Could anyone give me some suggestions? Thanks!
|
|
|
|
|
mathewzhao wrote: I tried to get a console handle by the sentence, ConsoleHnd = GetStdHandle(STD_OUTPUT_HANDLE);
Unfortunately,I got the following error message:
error: argument of type "HANDLE" is incompatible with parameter of type "HWND".
Use GetConsoleWindow .
|
|
|
|
|
use CreateProcess(..) function to launch a console, you can get handle of the console window there.
GetStdHandle(...) is related to handle of input/output buffer, which are not window's handle.
|
|
|
|
|
i want to send a mail using smtp but i do not want to specify mail address of a particular person
how can i do this
|
|
|
|
|
neha.agarwal27 wrote: i want to send a mail using smtp but i do not want to specify mail address of a particular person
I believe you atleast need to specify one email address, to whom the email is to be sent.
This link[^] would help you.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|