|
Thanks very much, I've done it completely and it works!
9ine
|
|
|
|
|
9ine wrote:
Thanks very much, I've done it completely and it works!
you're welcome... i'm always happy when i reach helping people usefully...
ps: if you liked my post, don't forget to vote for it !
ps 2 : i edited my previous answer[^] to consider using pointers.
cheers dear,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I'm using VC7 and MFC.
I create a ListBox control using the dialog editor and the toolbox and I attach it a control variable of the type CListbox.
On the other hand I create another list manually, declaring a CListBox variable and calling Create.
I use AddString to add new items, but the fonts are different. The manually created list has some kind of bold font.
I have tried everything. Changing the create styles, trying to use CreateEx, but I cannot get they to look the same.
I have the same problem with combo boxes.
I would appreciate any idea. Can anybody help me?
|
|
|
|
|
I think that the code that is generated for you to create the control you dragged on includes code to set the font. I believe it has a Font property, or something like that.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thank you very much for your fast response.
I decided to create those controls manually because I have a dialog window with edit controls, list boxes and combo boxes.
If I use the dialog editor and attach the control variable to them, some work properly when I add data, but others raise the error ERROR_INVALID_WINDOW_HANDLE.
And I do not destroy the dialog window or the controls.
Thank you again for our fast response.
|
|
|
|
|
mpuerto wrote:
If I use the dialog editor and attach the control variable to them
How do you mean ?
Another way to do this if you have multiple things on the form, is to put them all there, and just hide the ones you don't want to see at any point in time.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I meant that I place a list box in the dialog, with the dialog editor (not coding, with the visual interface), right from the toolbox. Then I attach a control variable to the listbox with the wizard.
When I try to add new strings to the listbox with AddString, it raises the error I told you before. But if I do everything coding: declare a variable of type CListBox, call Create and then AddString it works properly.
Can it has something to do with the fact that I declare the dialog class as DECLARE_DYNAMIC?
Thank you again for the help and sorry for the misunderstanding.
|
|
|
|
|
Oh, I get you now. I'm sorry, I really don't know the answer to that question.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
mpuerto wrote:
When I try to add new strings to the listbox with AddString, it raises the error I told you before.
Any chance you are calling AddString() before the execution of your dialog's OnInitDialog()?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Sorry, I think that's not the case. Because I call AddString when I press a button in the dialog. If I call InitStorage the same error takes place.
Thank you for answering.
|
|
|
|
|
When you create a control by adding it via the dialog editor, the control automagically uses the font of the dialog. If you create the control manually via Create() you have to set the font yourself, or else it will use the default system font. You can use GetFont to get the dialog's font, and SetFont to set the control's font.
CMyListBox.Create(...);
CMyListBox.SetFont(GetFont());
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
I am working on a VC++ project in which
UserInterface is an
exe and also a service is running for the
application.My problem is
when i switch between one user in WIN XP to another I
am not able to pop
up the userinterface in new user environment.My
service is autmatic on
task manager i am able to get userinterface exe for a
while but it dies
.when we check the task manager of first user I can
see both
usrinterface and the related service on task
manger.How can i pop up my user
interface when we switch from one user to another.
|
|
|
|
|
Hello Friends,
Kindly observe the code given below
#include <iostream.h>
void show(int x)
{
cout <<"inside the function one " << x << endl;
}
template <class t=""> void show( T a)
{
cout << "inside the template" << a << endl;
}
int main()
{
show(10);
return 0;
}
When I run this program , I get the output
"inside the function one 10".
My question is why the template function is not get executed
and only simple function get executed only"void show(int x)".
Can any one help me in this matter?
|
|
|
|
|
You need to check 'Do not treat <'s as HTML tags' for us to see the code properly.
Christian Graus - Microsoft MVP - C++
#include <iostream.h>
void show(int x)
{
cout <<"inside the function one " << x << endl;
}
template <class T> void show( T a)
{
cout << "inside the template" << a << endl;
}
int main()
{
show(10);
return 0;
}
When I run this program , I get the output
"inside the function one 10".
|
|
|
|
|
phijophlip wrote:
int main()
{
show(10);
return 0;
}
Of course you do, what else could happen ?
show(10) will call the non-templated function, and without that function, would be a compiler error
show<int>(10) will call the second function and will not compile if only the non templated function exists.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
i am working on making a mediaplayer.I have to add directories at run time.The files in the folder path should be added to list control along with existing files .iam using SHBrowseForFolder .I am adding foler path to environment variable.List should update and display all files according to the path in environment variable set .List should reside on reboot . Now it is showing the most recently navigated folder.On reboot it 's null.
all files are video files .
Thanks for going through my message
|
|
|
|
|
geo19762005 wrote:
List should reside on reboot
trying to understand the above line, can you please help.
suhredayan There is no spoon.
|
|
|
|
|
Is there some reason you try to manipulate the environment strings?
You could more easily store your setting for each user in the registry under HKEY_CURRENT_USER\Software\<yourcompanyname>\<yourprogramname>\Preferences
Then make a REG_SZ (string) value and called FoldersToCheck and save the folders the user selected, perhaps separated by semicolons or something. Or make a key called FoldersToCheck and then make individual values under it Folder1, Folder2, etc. That is up to you.
|
|
|
|
|
I have a class TstClass, In the TstClass.cpp I declare 3 function, 2 are TstClass funxtions, 1 is general functions...
CTstClass.cpp:
...
...
void Process1( void (*pDataRecept)( CString sDataList ))
{
....
}
BOOL CTstClass::GetData()
{
...
Process1( DispData );
...
}
void CTstClass::DispData( CString sData )
{
...
}
But I got Compilling error : error C2664: 'Process1' : cannot convert parameter 1 from 'void (class CString)' to 'void (__cdecl *)(class CString)'
What is the reason? Thanks!
|
|
|
|
|
DispData is a member of CTstClass. The prototype calls for a 'void (__cdecl *)(class CString)'
|
|
|
|
|
As DispData is a member function from the CTstClass, it has an implicit parameter that is passed to the function: the this parameter. Thus, the function prototype does not match.
To avoid that, make your member function static (but then, inside the function you won't be able to play with non-static members).
|
|
|
|
|
In my application I want to access files, where the underlying character type (ASCII or Unicode) is transparent for the application.
Suppose that in a reporting module a report is written to file, like this:
myfile << reportHeader << std::endl;
for (all columns) myfile << columnname;
myfile << std::endl;
for (all records)
{
for (all columns) myfile << data;
myfile << std::endl;
}
Now, I want my application to transparently write the report to ASCII or Unicode files, depending on the user specification.
Currently, you have to do it like this:
std::ofstream asciiFile;
std::wofstream unicodeFile;
if (user wants Unicode)
{
unicodeFile.open ("output.txt");
unicodeFile << reportHeader << std::endl;
}
else
{
asciiFile.open ("output.txt");
asciiFile << reportHeader << std::endl;
}
for (all columns)
{
if (user wants Unicode) unicodeFile << columnname;
else asciiFile << columnName;
}
... and so on
The disadvantages seem obvious:
- clumsy, unreadable code (especially if the write-to-file logic is spread over several methods)
- writing Unicode strings (std::wstring) to an Ascii stream doesn't even work; it produced garbage
Therefore, I need a kind of transparent stream, so that I can write the following:
transparentstream myfile;
myfile.setMode (ascii or unicode);
myfile.open ("output.txt");
myfile << reportHeader << std::endl;
for (all columns) myfile << columnname;
myfile << std::endl;
for (all records)
{
for (all columns) myfile << data;
myfile << std::endl;
}
Problems are:
- from which stream do I inherit the transparentstream?
- how do I define the transparentstream so all defined output operators keep on working?
- where do I put the conversion logic? (basic_buf? basic_filebuf?)
Of course I want something similar for input, where the stream can find out itself whether the file is Unicode (starts with 0xfffe or 0xfeff) or plain Ascii.
And as an additional challenge: is it possible to have such a transparent stream that can do something like this?
transparentstream mystream;
mystream.open("http://www.mywebsite.com/mypage.html");
mystream >> ...;
And if this is possible, how do I implement such a stream of buf class?
Did some of you already encounter problems trying to mix the STL and Unicode files?
How did you solve it?
Probably Java and .Net solve this problem in a elegant way, but I really need a solution using only STL.
Thanks for you suggestions.
Enjoy life, this is not a rehearsal !!!
Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
My first thought is to encapsulate the ASCII and UNICODE streams with in your own class (or template) then duplicate the methods. It may be as simple defining operators for both char and wchar_t (I dought it thou).
class transparentstream
{
std::ofstream asciiFile;
std::wofstream unicodeFile;
...
};
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Is there a way to enumerate the windows of an application from it's process id?
thanks
|
|
|
|
|
I am not aware of a direct way.
Look at EnumWindows followed by a call to GetWindowThreadProcessId to correlate the known PID with the enumerated HWND.
To be really thorough, you can also EnumWindowStations followed by EnumDesktops followed by EnumDesktopWindows followed by GetWindowThreadProcessId
|
|
|
|