|
Maximilien wrote:
and what are RAII ?
"Resource Acquisition Is Initialization". Do a Google search on "C++ RAII" etc.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
i get the handle of a textbox in an opened window using the function
EnumChildWindows(,,)..
after i obtained the handle of this textbox i want to set a specific
string in this textbox.
"HINT" : the function SetWindowText(,) isn't a valid to this task(why?)
more--->
the opened window has a textbox ,a button ,a label;
and when i used the spy++ program of Microsoft tools to get the caption
to each of them after using SetWindowtext(,),i observed that:
the caption of the label is same as the value appears on it<the
caption="" and="" value="" appears="" are="" equal="" to="" each="" other="" the="" string
posted="" by="" setwindowtext()=""> ,BUT
the caption of the textbox isn't the same as the value appears on it
<the value="" is="" nothing="" but="" the="" caption="" equal="" to="" string="" posted="" by=""
setwindowtext()="" function="">then i want an API function to set the value of the textbox not the
caption..
thank you very much for any help..
Sender :Amr abdel mohsen
Email: app_prog@yahoo.com
amr abdel mohsen
|
|
|
|
|
You can't use SetWindowText to set the text of a textbox; SetWindowText sets the text of the window itself.
- Nick Parker My Blog
|
|
|
|
|
No.....
SetWindowText sets the text of _any_ window. Everything in Windows is a window, including simple controls. What the window does when it gets a WM_SETTEXT message varies between what it is.
A popup window (ie a normal window with a caption) sets it's caption
A button sets it's label
A edit control sets it's text
"This function changes the text of the specified window’s title bar, if it has one. If the specified window is a control, the text of the control is changed. For an edit control, the text is the contents of the edit control. For a combo box, the text is the contents of the edit-control portion of the combo box. For a button, the text is the button name. For other windows, the text is the window title."
Etc etc.
Assume when you say "textbox" you mean edit control. What may be causing you grief is the fact that the window handle belongs to another process and SetWindowText first validates the Window (if it's a control) to see if it belongs to the calling process.
Rather than use SetWindowText, do it manually with WM_SETTEXT
LPCTSTR pszTextToSet = "Hello";
::SendMessage(hWndTheControl, WM_SETTEXT, 0, (LPARAM)pszTextToSet);
|
|
|
|
|
Diddy wrote:
SetWindowText sets the text of _any_ window. Everything in Windows is a window, including simple controls. What the window does when it gets a WM_SETTEXT message varies between what it is.
Thanks for correcting me Diddy.
- Nick Parker My Blog
|
|
|
|
|
Hi All,
I am converting a project from VC6 to .net2003 and am running into a compiler error with my (user) message maps. I can't see what is wrong - worked fine in VC6...
Here is the compiler error:
SimParamsDialog.cpp(80) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CSimParamsDialog::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
None of the functions with this name in scope match the target type
Here are the message maps:
- these defines are actually in a .h file
#define WM_LOADSENSORSTOGRID WM_USER + 1
#define WM_LOADCALDATATOGRID WM_LOADSENSORSTOGRID + 1
BEGIN_MESSAGE_MAP(CSimParamsDialog, CFormView)
//{{AFX_MSG_MAP(CSimParamsDialog)
ON_BN_CLICKED(IDC_BUTTON_SENDALARM, OnButtonSendAlarm)
ON_WM_TIMER()
ON_MESSAGE(WM_LOADSENSORSTOGRID, OnLoadSensorsToGrid)
ON_MESSAGE(WM_LOADCALDATATOGRID, OnLoadCalDataToGrid)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
and the function(s):
void CSimParamsDialog::OnLoadSensorsToGrid(WPARAM wParam, LPARAM lParam)
{
etc
}
void CSimParamsDialog::OnLoadCalDataToGrid(WPARAM wParam, LPARAM lParam)
{
etc
}
Any ideas? Again this works in VC6...
Thanks
John
|
|
|
|
|
AFAIK your functions have to return an LRESULT, not a void.
LRESULT CSimParamsDialog::onloadSensorsToGrid(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
LRESULT CSimParamsDialog::onloadCalDataToGrid(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks - that did it!
Worked fine in VC6...odd that it didn't catch that.
John
|
|
|
|
|
Me stupid me need help. Me Inteligence 3 (AD&D 2.0).
Look, I really neeeeed heeeeeeeeelp (F1 F1 F1, bloody button doesn't work .
I have a litle problem of converting std::string to LPSTR or const char *something and vice versa. Heeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeelp???
<<s@t@n>>
|
|
|
|
|
std::string::c_str() will return a const char * .
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
What are some good books for C++ programming (Beginner type stuff)?
|
|
|
|
|
For Visual C++ specifically, Practical Visual C++ 6 is the best I've seen. You can still get it at Amazon.com[^].
Heard in Bullhead City - "You haven't lost your girl - you've just lost your turn..." [sigh] So true...
|
|
|
|
|
I like "The C++ Primer" (3rd) by Stanley Lippman et al.
Maxwell Chen
|
|
|
|
|
If you are only new to C++ (as opposed to being new to programming), I can recommend "Accelerated C++" by Koening/Moo.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
I found the problem!!!
I Replaced the critical sections by local variables CMutex and it solve the problem. But more strange is the fact that if I remove the CMutex object, it is still working I have no acces conflict!
So I don't really understand the utility of critical sections since my threads looks smart enough to wait for each other to finish accessing the shared variables...
(NB: I found this AFX_THREADPROC synthax in the MSDN.)
Thanks a lot for your time Diddy and have a nice evening!
|
|
|
|
|
"local variables" as in local to the functions?! Unless they are named mutexes you will be unlocking and locking different mutexes.
"smart enough to wait for each other to finish accessing the shared variables...".......... Hee hee.... Well, run it 100 times and 80 of them might work, but threads are threads and if they are both reading and writing to the same shared data, without any syncronisation objects, you are asking for trouble. Unless the operations to do the reading and wring are single step operations, for example u are much less likley to runinto trouble sharing a simple int (the worst that could happen is you get the wrong value) as to a shariing a string - which is a multistep opeation and you one thead could pre-empt the other halfway through the process.
The casting to AFX_THREADPROC ? Very strange, I've always seen it as LPVOID then cast in the thead - function pointer casting makes me nervous
Anyway, if it works, who cares!
Have a nice evening yourself
|
|
|
|
|
I'm attempting to use the oralib Oracle OCI wrapper library in my VC++ 6.0 project. It's giving me a number of linker errors (see below).
Has anyone used this library successfully?
Thanks!
--------------------Configuration: RAD_DataAnalysis - Win32 Debug--------------------
Linking...
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(void)" (??1?$basic_strin
g@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) already defined in oralib.lib(statement.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::out_of_range::out_of_range(class std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> > const &)" (??0out_of_range@std@@QAE@ABV?$basic_string@DU?$char_tr
aits@D@std@@V?$allocator@D@2@@1@@Z) already defined in oralib.lib(statement.obj)
msvcprtd.lib(MSVCP60D.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >(char const *,class std::a
llocator<char> const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBDABV?$allocator@D@1@@Z) already defined in oralib.lib(statement.obj)
LIBCMTD.lib(fpinit.obj) : error LNK2005: __ldused already defined in a previous module
LIBCMTD.lib(fpinit.obj) : error LNK2005: __fltused already defined in a previous module
LIBCMTD.lib(dbgheap.obj) : error LNK2005: _malloc already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in msvcrtd.lib(cinitexe.obj)
LIBCMTD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in msvcrtd.lib(MSVCRTD.dll)
LIBCMTD.lib(dosmap.obj) : error LNK2005: __errno already defined in msvcrtd.lib(MSVCRTD.dll)
msvcrtd.lib(MSVCRTD.dll) : error LNK2005: __setmbcp already defined in LIBCMTD.lib(mbctype.obj)
LINK : warning LNK4098: defaultlib "msvcrtd.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMTD" conflicts with use of other libs; use /NODEFAULTLIB:library
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/RAD_DataAnalysis.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
RAD_DataAnalysis.exe - 17 error(s), 2 warning(s)
|
|
|
|
|
Looks like the objects in oralib.lib are linked to the static multithreaded version of the C runtime library, but your project is configured to use the DLL. Change your project to use the debug multithreaded version, or obtain a version of oralib.lib which uses the DLL.
To change this setting, go to Project > Settings, the C/C++ tab, change the Category drop-down to Code Generation, then under 'Use run-time library' select Debug Multithreaded.
|
|
|
|
|
I am working on a toolbar in IE, which is a COM DLL. There is one instance of the toolbar for each IE window. I'd like to know how to find out the relationship in between. For exampe, if I know the HWnd of an instance of toolbar, how can I know the HWnd of its IE window? I tried GetParent of my toolbar instance. It is not working. I also tried (HWND) GetWindowLong (hWnd, GWL_USERDATA). Still not working.
Please help me.
Thanks a lot in advance.
|
|
|
|
|
I've never done any database project and I dont' know how to start. I saw several article about database using c++.net, ADO.net, VB.net,..etc they really confused me.
if I want to create the sample table using MS Access, how? I read some article on Microsoft.com about ADO is better than Automation MSAccess. But I just don't see any article about how to start or begin, creating a simple table with MS Access.
which language I should use c++, vb, or c#. I'm using .Net
and Can you please guide me how to begin please...
thank you
|
|
|
|
|
There is no 'best' language for a database project; it is more dependant on the target platform.
If you are programming for a web page, then PHP is the thing to choose, but if you're attempting to create desktop software with database access, I suggest dwelving into ODBC and MFC's support for ODBC (CDatabase, CRecordset & CRecordview).
Here's a link to the MSDN Library site for database programming with MFC[^].
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Created a Dialog application last night with Menu, one of the choices in the menu is another dialog window which I created a separated class for. However tried to initialise the dialog, but unable to do so. (Note: that this dialog has a FlexGrid and this is what I'm trying to initialise)
Suggestions much appreciated
Kind Regards
Caoimh
|
|
|
|
|
Please be a little more specific. What do you mean with "tried to initialise the dialog"?
Usually you open a new dialog in a dialog based app like this:
At the top of the file:
#include "MySecondDlg.h" At the place where you want to open the dialog:
CMySecondDlg dlg;
dlg.DoModal(); That's it...
Regards, mYkel
|
|
|
|
|
I've done it exactly as you indicated but what if you want to initialise values in a Grid like FlexGrid or even an edit box?
Kind Regards
Caoimh
|
|
|
|
|
All initialisations of a dialog are usually done in the OnInitDialog() method.
The method OnInitDialog() gets called before a dialog is shown.
So just start the dialog as you have done it already and handle OnInitDialog()
in your CMySecondDlg(). Here's a short example:
MyFirstDlg.cpp:
#include "MySecondDlg.h"
...
CMySeconDlg dlg;
dlg.DoModal() MySecondDlg.cpp:
BOOL CMySecondDlg::OnInitDialog()
{
...
myEditBox = "Just an example..."
UpdateData(FALSE);
} Normally the OnInitDialog() message handler is create by default, so you just have to add your initialisations like above. Otherwise you have to create this message handler by yourself.
Regards, mYkel
|
|
|
|