|
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]
|
|
|
|
|
Yes, but if I use PreTranslateMessage I canot call the event that I need to handle, at least I don't know how to do it...
In the PreTranslateMessage I have tried:
<br />
if ((pMsg->message == WM_KEYDOWN) && ((int)pMsg->wParam == VK_RETURN))<br />
{<br />
if (pMsg->hwnd != this->m_cLCtrlIntroduccio.GetSafeHwnd())<br />
{<br />
return TRUE;<br />
}<br />
}<br />
in order not to be able to process the enter key in any other control.
but then I also cannot reach:
<br />
MyClass::OnReturnLctrlIntroduccio(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
AfxMessageBox("return detected in the ListCtrl");<br />
*pResult = 0;<br />
}<br />
because the property sheet disappears in the same way...
|
|
|
|
|
Ah. What I meant was that you detect that the input message is aimed at your edit window, and send the message normally (there are different ways to do this) before returning TRUE.
if (pMsg->message == WM_KEYDOWN &&
pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)
{
CEdit* edit = m_TreeCtrl.GetEditControl();
if (edit)
{
edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
You can also replace the SendMessage with
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
if you want to.
This should work as you require.
Sorry for any confusion.
Steve S
[This signature space available for rent]
|
|
|
|
|
Great!
sorry, this was really clear, it's my fault, tonight I haven't sleeped and I'm very tired
thank you very much!
|
|
|
|
|
How do I convert a CString to a _bstr_t?
Thanks,
ns
|
|
|
|
|
_bstr_t bstrText = L"text";
CString strText = (LPCWSTR)bstrText;
CString strText2 = (LPCSTR)bstrText;
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
The other way round:
I have CString a ="abc";
I want to make this a _bstr_t, so that I have:
_bstr_t ab = SOmethingDoneTo (a)
Thanks,
ns
|
|
|
|
|
Incidentally, whats the L mean here from your snippet?
L"text";
Thanks,
ns
|
|
|
|
|
To answer both of your questions:
ns wrote:
Incidentally, whats the L mean here from your snippet?
It means that the hardcoded text shall be interpreted as a string of wchar - not char. In other words:
char* pszText = "this is a text";
wchar_t* pszwText = L"so is this";
char* pszText2 = L"doesn't work";
wchar* pszwText2 = "doesn't work either"
To answer your other question - to convert from CString to _bstr_t you can use:
CString strText = _T("This is a text");
_bstr_t bstrText = (LPCTSTR)strText;
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Here is a code fragment:
void CShelf2Dlg::OutStr(CString Str, int Port)
{
VARIANT va;
va.vt = VT_BSTR; // The variant is storing a string
va.bstrVal = Str.AllocSysString(); // Convert the CString to the VARIANT
Comport[Port]->SetOutput(va); // and output it
}
Elaine (fluffy tigress emoticon)
Would you like to meet my teddy bear ?
|
|
|
|
|
Well, I did
_bstr_t b_dataBaseName = SysAllocString (dataBaseName);
where dataBaseName is a char* and get the error:
error C2664: 'SysAllocString' : cannot convert parameter 1 from 'char *' to 'const unsigned short *'
Thanks,
ns
|
|
|
|