|
If opened in Text mode (the default), the MS C run-time treats the file as if it is ANSI (i.e. encoded using your default locale's character set). fgetws passes the data read through MultiByteToWideChar to get a UTF-16 string.
If the file is already UTF-16, you'll get the wrong answer (what you're seeing here).
Files opened in Binary mode (by adding a 'b' to the mode parameter) are treated as-is, with no conversions. This also means that CR+LF pairs are not converted to line feeds alone: you'll see \r as well as \n.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Ok, thanks for the help! So I'll just try reading the file as binary, and see how that works.
Is using fgetws the best way to fill a char array with the contents of a file, in a straight-Win32 app?
|
|
|
|
|
I have a dialog resource IDD_FORM_XXX in a project. I want to use this resource in another project. Can I copy the dialog resource into the other project?? I cant figure out how to do it...or how to import it.
Thanks.
Jerry
|
|
|
|
|
If nothing else you could copy the dialog from the resource (.rc) file and paste it into the new project.
- Aaron
|
|
|
|
|
I tried that. I dont know why but that will not work.
Jerry
|
|
|
|
|
Make sure you paste it in the dialog section of the new rc file. You will probably have to modify your resource.h for the IDs too.
"We have done so much in the last 2 years, and it doesn't happen by standing around with your finger in your ear, hoping everyone thinks that that's nice." - Donald Rumsfeld
|
|
|
|
|
open the two .rc (src and dest) file only in the same IDE.
then drag and drop from one window to another, if you hold the ctrl key down a copy will be made, else the resource will be moved.
Regards.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Hi there,
Is there a way I can create a CComboBox pointer for a combo box that I have created within Resources? I want to be able to add items dynamically depending on user input. Whey can't it just do that in C++ like it does in ASP for select controls. The reason I ask is because I can't seem to position the dynamic combo box where I would like it. How to I find the coordinates for its position in order to position it properly?
For example, I have created a combo box in a dialog box which I will call IDD_COMBO. Its member variable defined in the header file is m_COMBO. Is it possible to add items to the box without having to create a CComboBox pointer?
Any help would be much appreciated. Thanks!
|
|
|
|
|
Right click on your combobox control, click class wizard...then click on member variables tab. Double click on IDD_COMBO in the list below and make sure your categorey is control NOT value.
Otherwise...
CComboBox* pControl = GetDlgItem(IDD_COMBO)
ASSERT(pControl);
pControl->AddString("My string ");
Cheers
How do I print my voice mail?
|
|
|
|
|
I had set the category to control and inserted the 3 lines of code above but it gave me the following error.
Error: cannot convert from 'class CWnd *' to 'class CComboBox *'
Also, how can I apply ON_CBN_SELCHANGE to a dynamic combo box?
Thanks!
|
|
|
|
|
If you set the categorey to control, you don't need the control pointer
instead you would
m_ctrlCombo.AddString("");
However, if your categorey was set to value because your relying on MFC's DDX and Updatedata() then keep it that way...so your combo is updated automagically...by the framework...
You will need a pointer if you want to add items dynamically...using AddString()...becuase value will store a member variable of type CString(I think) not CComboBox you can't call the string with a function like AddString...
Cheers
How do I print my voice mail?
|
|
|
|
|
Thanks Hockey! It worked!!!
|
|
|
|
|
In the class I'm writing I'm using the string type from the STL. The problem I'm encoutering is that when I compile I'm getting warning 4530 in a bunch of the STL string files. The warning is "C++ exception handler used, but unwind semantics are not enabled. Specify -GX" I see that I can just add the -GX compiler option, but I want to know why I'm getting this warning. I've used string before and never had this problem. In my header I have
#include <string>
using namespace std; Am I doing something wrong here?
- Aaron
|
|
|
|
|
MSDN states you need to enable exception handling for any of the standard C++ library.
http://support.microsoft.com/default.aspx?scid=kb;en-us;q154419[^]
Why you didn't get this warning before??? Maybe you weren't using MS STL Or perhaps your proejct settings already included this compiler switch?
Check out #pragma warning to surpress this warning
How do I print my voice mail?
|
|
|
|
|
Thanks for the info. Not sure why I never got the warnings before but I guess I'll enable the exception handling and clear those pesky warnings.
I was going to use #pragma warning but I'd actually have to put it in each file that was causing the warning...probably not a good idea.
- Aaron
|
|
|
|
|
Cheers
How do I print my voice mail?
|
|
|
|
|
Some project types, e.g. MFC projects, have /GX (/EHsc) enabled by the AppWizard. Others don't.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
That would be why then, the project wasn't an MFC one. Thanks for the info.
- Aaron
|
|
|
|
|
Hi
As far as I know there are two types of dialogs. Modeless and Modal.
Now according what it says here : [url]http://www.devarticles.com/c/a/Cplusplus/Using-MFC-in-Cplus-Dialog-Boxes/4/[/url] and also on Microsft's MSDN site that to create Modeless dialog I must call Create() function and DestroyWindow() function. Whereas for the modal dialog I only call DoModal.
Now I am confused as my dialog does not call any of those functions and I am still able to display it.
The dialog initialization is:
BOOL CProgressDlg::OnInitDialog()
{
CDialog::OnInitDialog();
ShowWindow(SW_HIDE); // Show or hide a control, etc.
return TRUE;
}
and to display I call ShowWindow(SW_SHOW);
and Close() function to close dialog:
void CProgressDlg::Close()
{
EndDialog(IDOK);
}
It works.! So what kind of dialog is this? I guess this is a modeless dialog as it doesnt need to wait untill the user presses OK button. Is it correct what I am doing here or its wrong? Please let me know.
My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
|
|
|
|
|
How are you creating your dialog object?
Modal's are (usually) created on the stack (or heap):
CMyDialog myDlg;
myDlg.DoModal()
When it goes out of scope, everything is cleaned up automagically...(if created on the stack)
robert_s wrote:
Now I am confused as my dialog does not call any of those functions and I am still able to display it.
Now I am confused...how are you creating a dialog if your no calling Create or DoModal???
robert_s wrote:
My second question: The dialog I created is used to display a progress bar while some text files are processed using a separate worker thread (thread used purely for files processing not for the dialog). The problem I have is when I start processing files the dialog with the progress bar appears but its behind the main window. How can I force it to display over the main window as the modal dialogs do? I guess WS_OVERLAPPED will do but where to use it?
SetForegroundWindow() ???
How do I print my voice mail?
|
|
|
|
|
Hey,
I am using Visual C++, and I created a Combo Box and added the options into it. Now, when someone selects one of the options, I want a text describing the option to appear in an edit box. I have looked around and only found a few things, but nothing really helped.
Thanks for the help
|
|
|
|
|
The combox by default displays the text in the list control in the edit box as each item is selected.
I'm not sure, but you could maybe try capturing ON_CBN_EDITUPDATE or ON_CBN_SELCHANGE and then forcing the edit to change it's value.
This approach won't work if the drop down list and edit field are dual synchronized. What I mean by this is if you set the edit content it make force a new item to be selected inside the list box as well and visa-versa.
If this is the case you will have to subclass the CComboBox control and override this functionality.
Cheers
How do I print my voice mail?
|
|
|
|
|
I tried doing that, didn't work, here is my code.
<br />
void CDEPDlg::OnSelchangeCombo1() <br />
{<br />
UpdateData(true);<br />
<br />
if(m_type1=="Run #1")<br />
{<br />
m_purp1="Test";<br />
}<br />
<br />
UpdateData(false);<br />
<br />
}<br />
m_type1 is the combo box, and Run #1 is the option in the combo box.
m_purp1 is the edit box that i want it to display the description.
I know it is wrong, so criticize all you want, just need help with it.
Thanks
|
|
|
|
|
It's been a while since I subclassed comboboxes or dealt with them for that matter
How did you get m_purp1 and m_type1 to map to the 2 controls that make up an CComboBox ?
How do I print my voice mail?
|
|
|
|
|
I went to the class wizard and did it there.
m_type1 is a CString and m_purp1 is a CString also
|
|
|
|