|
You can use _bstr_t class to manipulate BSTRs. See MSDN.
Pavel
Sonork 100.15206
|
|
|
|
|
There are a whole bunch of conversion macros. You will have to look up MSDN for which one you need. Searchfor A2W, A2OLE, USES_CONVERSION. You should be able to find the right macro. Or alternatively use the _bstr_t class.
|
|
|
|
|
|
Kinda new to MFC and I got what will probably be a simple question for everyone to answer. In regards to property pages and tab pages, do the controls that you put on them have to be created at runtime? I know with just a simple dialog I can use the resource editor to add controls at design time but I'm not sure how to do it with property pages and tab pages.
Thanks for the help.
- Monrobot13
|
|
|
|
|
monrobot13 wrote:
do the controls that you put on them have to be created at runtime?
No, you can work with your CPropertyPage derived classes like with CDialog derived ones. Use wizard to add property sheet with pages to your project: in VC6 menu select Project/Add to project/Components and Controls, then go to Visual C++ Components, select Property sheets and press Insert.
Pavel
Sonork 100.15206
|
|
|
|
|
-> First of all excuse my English
-> My answer:
You can, but you don't have to,
You have to create the property pages (tabs) and the property sheet (tabs recipient) separately.
In order to do that, you must create the property sheet class:
1. Menu insert -> new class.
2. Type the new class name.
3. Select the CPropertySheet base class.
Now you have the property sheet created, but this won't have any tab (property page).
To create pages (PropertyPages) you will have to:
1. Create a dialog resource (a normal dialog)
2. in the dialog properties select:
2.1. (Tab styles) Style = child
2.2. (Tab styles) Border = thin
2.3. (Tab styles) checked Title Bar (the other options in this tab must be unchecked)
3. Doubleclick the dialog (in order to create a new class for it)
3.1. Write the new name of the class.
3.2. Select the CPropertyPage base class.
Now you have created a property page and a property sheet, you can create all the property pages you want. (Surely there will be a limit of property pages, I don’t know it…)
Now you have to insert the property pages to the property sheet.
In order to do that:
Make sure that you have included the header files of the PropertyPages in the header file of the Property Sheet:
<br />
#if !defined(AFX_PSPARAMETRITZACIONS_H__8CB4FA88_5A89_4479_A479_4734680B1775__INCLUDED_)<br />
#define AFX_PSPARAMETRITZACIONS_H__8CB4FA88_5A89_4479_A479_4734680B1775__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#include "PPDlgParametritzacions.h" <br />
…<br />
And you should add a PropertyPage variable for each PropertyPage that you want to add:
CPropertyPageClassThatYouWillHaveAdded m_CPPCTYHA;
In the constructor of the Property sheet class you should add the PropertyPages:
this->AddPage(&m_CPPCTYHA);
And that’s all…
(Just kidding…)
You will need to call the Property sheet:
In order to do that:
You should include the CMyPropertySheet class (header file) to the header file of from where you want to include the property sheet call.
Add a variable of the type CMyPropertySheet in the same class (dialog or xxx) from where you want to call the property sheet:
CMyPropertySheet m_MyPropertySheet;
(In order to try it you can create a CButton in a dialog) and in its click event you can call
m_MyPropertySheet.DoModal();
Hope this helps...
Its possible that I have done a typing error or that I have missed something, if this don't works, email me (or try it by yourself...).
|
|
|
|
|
Thanks for the info that helps out quite a bit. Just so I'm clear is it pretty much the same deal for tabpages?
|
|
|
|
|
AAArgh!
what a mess!
I have written down a lot for nothing!
sorry, as I told you I'm not a natural english speaker...
but, I think that there is an article that can help you:
http://www.codeproject.com/listctrl/listctrldemo.asp
it is a listctrl article, but it uses tabcontrols...
hope this helps more...
sorry, you must be still laughing...
|
|
|
|
|
I think you miss read my message because your post actually helped me out and I didn't really see any problem with your english at all. Sorry if it sounded like it didn't help me.
|
|
|
|
|
I want to create a list of five currencies, which can be selected by typing the number 1 thru 5. Depending on the number selected would display a message to input a currency amount. The currency amount would then perform a calculation and display the amount in US dollars. If a number or character other than 1 thru 5 is selected, then an error message would display, and a prompt to select the correct number.
|
|
|
|
|
Cool school assignment. I hope you will have an A for it (by yourself).
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
I need to include a .lib file in my project and to use
classes defined inside it.
I have set the name of the .lib file in the project
settings (Link section)and I have placed it in the
project folder.
Now I don't know how to access to the library content !!!
What have I to do???
Thanks a lot
|
|
|
|
|
Include its header file. If its Windows lib, see documentation in MSDN.
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
Just one additon:
Instead of adding the file to the project settings you can also put this line into your sourcecode:
<br />
#pragma comment(lib, "yourlib.lib")<br />
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have a problem with a DialogBox where the code and it's resources are all in a DLL. I want the dialog to act like
a Dialog based app when it is "called up". Meaning I want it to have a taskbar icon, minimize, etc. I have disabled the Maximize and Size
commands from the system menu. The dialog can be "called up" by an entry point in the DLL, or by a RUNDLL32 style entry point
int the dll. The dialog behaves properly under W2K, but under Win9X I get no taskbar icon and when I minimize the dialog I get a
very small window that sit right above the taskbar in the lower left corner of the screen.
Can anyone provide me with some help on this ?
Thanks in advance
Tony Teveris
Here is my dialog setup
IDD_FONTMANAGER DIALOG DISCARDABLE 0, 0, 500, 293
STYLE DS_MODALFRAME | WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION |
WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Gerber Font Manager"
MENU IDR_MENU1
FONT 8, "MS Sans Serif"
BEGIN
.
.
.
END
Here is the dialog class init
CFontManagerDlg::CFontManagerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFontManagerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFontManagerDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDI_FONTMANAGEMENT);
.
.
}
Here is my Dialog INIT code
BOOL CFontManagerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// subclass self draw listboxes
// m_Styles_List.SubclassListBox(IDC_STYLES_LIST,this);
m_NotSecured.SetTextColor(FT_I_NOT_VALID_FONT_COLOR);
m_NotInCatalog.SetTextColor(FT_I_NOT_ON_CD_COLOR);
m_NotInCatalog.SetWindowText("");
CMenu* pSysMenu = GetSystemMenu(FALSE);
pSysMenu->EnableMenuItem (SC_MAXIMIZE,MF_BYCOMMAND | MF_GRAYED);
pSysMenu->EnableMenuItem (SC_SIZE,MF_BYCOMMAND | MF_GRAYED);
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
.
.
.
return TRUE
}
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
If I have a CEDit and a "DONE" button, after I finish entering text and press DONe, I can do something with the GetWindowText
from the edit.
What I want is for the user to hit Enter after he is all done entering text in the CEdit and then for the code thats in the OnDone function to run. (So I do not even have a DONE button). Somehow I want a function to run when I hit enter on this CEdit (and not anywhere else on the UI). Its done commonly in all Windoiws apps but all I have found is EN_CHANGE for CEit and taht just traps character by character, not on the final Enter.
Thanks,
ns
|
|
|
|
|
Use GetWindowText and your OnDone code in CMyDialog::OnOk() asuming it's a Dialog your using.
Or read Mike Dunn's FAQ thers's a link on top of the page!
van Padoea.
|
|
|
|
|
One way would be to override PreTranslateMessage in your dialog and catching the enter key:
BOOL CMyDialog::PreTranslateMessage( MSG* pMSG )
{
if ( pMSG->message == VM_KEYDOWN && pMSG->wParam == VK_RETURN )
{
if ( GetFocus( ) == &m_wndMyEditBoxThatIWantToCatchTheEnterKeyIn )
{
}
}
}
Of course there are many other ways also.
Hope this helps,
- d a b s -
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Okay. I already have in my prestranslate message:
if ((pMsg->message == WM_KEYDOWN))
{
if (pMsg->wParam == VK_RETURN)
{
return TRUE;
}
}
and dont know why or how (can you explain?), but it prevents the Cdialog from getting dismiised with an Enter. If I do your code idea, will the dialog vanish after pressing Enter? Thats what I want to happen, but if the user presses enter any other place other than the editbox , i dont want the dialog to vanish. Also a blank Cedit should not be able to be dismissed with Enter. Will your code if I replace mine with yours, so that? Or do I have to do (modified your code in red):
if ( pMSG->message == VM_KEYDOWN && pMSG->wParam == VK_RETURN )
{ //It's the enter key - check if your editbox has the focus:
if ( GetFocus( ) == &m_wndMyEditBoxThatIWantToCatchTheEnterKeyIn )
{ //Do stuff here... }
return TRUE
}
Thanks,
ns
Thanks,
ns
|
|
|
|
|
Yes this should work - only return TRUE if your editbox has the focus when the enter key is pressed.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Wait , wait.....I'm not there yet (sorry).
The way it originally was, what exactly did trapping those messages do? The dialog only vanished when I pressed DONE ( with EndDialog). SO the return TRUE seems to make my dialog unresponsive to any ENTERs....
Sorry to bother you but can you please explain what exactly is happening when TRUE is returned? MSDN says:
Return value : Nonzero if the message was translated and should not be dispatched; zero if the message was not translated and should be dispatched.
so when TRUE is returned, this means ignore these keystrokes. SO if I do a return TRUE within your focus checking if condition, this means my enter will be ignored? .....confused. I thought it would be:
if (focusonedit)
{do stuff}
else
return TRUE
What I understand you are saying is
if (focusonedit)
{
do stuff
return TRUE
}
Want the dialog to respond to Enter only when focus is on edit, and I am confused as to which one to use (the fisrt or second
of the two above.
Appreciate your help greatly.
ns
Thanks,
ns
|
|
|
|
|
Try them both and see what happens! (hint: RETURN TRUE discards the keypress)
You'll learn more by trying yourself!
Good luck!
van Padoea!
|
|
|
|
|
hello,
first of all let me thank you in advance, excuse me for my english, it's not my best.
I have some property pages that have ListCtrls (in report mode), and I'm editing the ListCtrl subitems, in order to begin the edition I want to allow the user to double click them (what is easy) and to hit the "enter" key in order to begin or finish the edition.
I've seen that there's a function that meets my needs:
OnReturnLctrl(NMHDR* pNMHDR, LRESULT* pResult)
this function works as the double click function (it use the same parameters).
The problem arises when I press the enter key, because I get the property sheet closed.
Could you give me an advice in order to be able to use the OnReturnLctrl(NMHDR* pNMHDR, LRESULT* pResult) and not to get out of the property page when I press the enter key?
NOTE
I would not like to remove the default buttons.
|
|
|
|
|
Return FALSE in CMyPropertyPage::OnApply()
thus
<br />
BOOL CMyPropertyPage::OnApply() <br />
{<br />
return FALSE;<br />
}<br />
van Padoea
|
|
|
|
|
This is also a general issue with dialogs that have controls on which support in-place edit. The real trick is not to override OnApply or OnOK (in the dialog case), but to use PreTranslateMessage at the control's parent window level, the dialog or property page.
There's an article on this in the controls/List Control or Tree Control section of CodeProject that describes how to do this, but I don't have the reference to hand.
Steve S
[This signature space available for rent]
|
|
|
|