|
Matteo_78 wrote: if(pEdit) pEdit->SetWindowText("Bla Bla");
doesn't work because we could think that pEdit is always !=NULL.
Well, we would not... and checking the pointer validity is always a good thing, either with ASSERT or by if
...
BTW, why do you new pEdit twice ? is pEdit a class member variable ? in DoSomething , which pEdit are you referencing ? the one allocated in InitType1 or in InitType2 ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
The code that I've posted was only an example, in my program the situation isn't so simple.
Yes, I'm checking pEdit before entering in this instructions.
About InitType1 and InitType2 and the doubled 'new': these are 2 different type of initalization functions of pEdit. And you could be sure that only one of InitType* was runned before DoSomething .
Thank you for your help;)
|
|
|
|
|
I use something like
if( ::IsWindow(pEdit->m_hWnd) ){
to verify that the window that the object references has been created and still exists.
GetSafeHwnd() will protect against the NULL this pointer and return the m_hWnd, but it won't let you knwo if the window exists, prior to sending a message.
Maybe you want soemthing like this:
if( pEdit && ::IsWindow(pEdit->m_hWnd) ){
|
|
|
|
|
did you look into the MSDN[^] ?
MSDN tells us :
CEdit::Create()
Creates the Windows edit control and attaches it to the CEdit object.
Return Value
Nonzero if initialization is successful; otherwise 0.
i think you'll find you hapinness there, won't you ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
CEdit* pEdit=NULL;
pEdit = new CEdit();
fun3()
{
if(pEdit!=NULL)
pEdit->SetWindowsText("Bla Bla");
}
Bye
Cool Ju
Vote for Cool Ju
|
|
|
|
|
how to indicate sorting icon in the list control on clicking column header.
knarasimharao
|
|
|
|
|
Check this[^]...
In CP one C# atricle is there on this ....
See this[^]....
Hope this will help you....
|
|
|
|
|
I have to write a program which shows a dialog when click on a button. After that, when click outside this dialog, it will be closed.
I've tried to use OnKillFocus function to check whether this dialog should be closed or not but it doesn't work.
Could u suggest me another solution to to this task?
Thanks in advance.
THE_TIME
|
|
|
|
|
OnActivate? (assuming you use MFC)
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I don't know how to use OnActivate function, could u tell me more detail?
Many thanks to your help.
Trunghd
|
|
|
|
|
trunghd wrote: I don't know how to use OnActivate function
MSDN[^] is your friend buddy...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I just tested this, OnActivate won't work for you. Since it's a modal dialog (which I assume it is) it won't receive OnActivate messages when you click outside the dialog. Similarly, you won't get any WM_LBUTTONDOWN or the likes when the user clicks outside your dialog. Instead, you must handle the WM_NCACTIVATE message:
In your dialog class header, put
<br />
afx_msg BOOL OnNcActivate(BOOL bActive);<br />
and put
<br />
ON_WM_NCACTIVATE()<br />
in the dialog class' message map.
in CYourDialog::OnNcActivate handle the case bActive==FALSE, this is when the user clicks outside the client area. Dismiss your dialog in whatever way is appropriate.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
trunghd wrote: but it doesn't work
What does not work ? You do not catch the WM_KILLFOCUS message, or does the message not get send when you click outside the dialog ?
Three possibilities here (from the best to the least good, IMO):
1- Catch the WM_ACTIVATE message( MFC using afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized ); and WA_INACTIVE as nState). In the message handler, dismiss your dialog.
2- Catch WM_KILLFOCUS, i still do not understand why this should not work
3- Handle WM_LBUTTONDOWN and WM_RBUTTONDOWN, check if the clicked position is inside the area of your dialog, if not, dismiss the dialog.
Hope this helps
~RaGE();
|
|
|
|
|
This program I have to write is very similar to the Undo button in MS Visual C++ 6.0. When click on a button, a new dialog which have a listbox within it appears. We can choose item in listbox. When we click outside the dialog, it will be closed.
I use Create()& SetWindowPos functions to put the new dialog at the bottom of this button.
Firstly, I've tried to use OnKillFocus to check when the dialog lost focus but I always get WM_KILLFOCUS message immediately after SetWindowPos function. So the dialog disappear immediately after appear.
Second, I've tried to catch WM_ACTIVATE message but I don't know how to check WA_INACTIVE or WA_ACTIVE in the WM_ACTIVATE message. Do I have to override OnActivate function to handle WM_ACTIVATE message.
Could u tell me more detail?
Many thanks for your help. It's very precious.
Trunghd
|
|
|
|
|
trunghd wrote: I use Create()& SetWindowPos functions to put the new dialog at the bottom of this button.
Firstly, I've tried to use OnKillFocus to check when the dialog lost focus but I always get WM_KILLFOCUS message immediately after SetWindowPos function. So the dialog disappear immediately after appear.
Ok, this explains why OnKillFocus is not our solution here.
trunghd wrote: I've tried to catch WM_ACTIVATE
I still do not know if you are using MFC, but I will assume it. If not, post back and i'll give you the plain Win32 code.
So override the WM_ACTIVATE message (I guess you know how to do, if not : Right-click on your dlg class in the class borwser, [Add Windows MEssage Handler], Set [Filter for messages available to class] (on the bottom right) combo box on [Window], Select WM_ACTIVATE in the left listctrl and Click Add Handler button).
Then
void CYourDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
if ((WM_INACTIVE == nState ) && (pWndOther == FromHandle(m_hWnd))
{
}
else
{
CDialog::OnActivate(nState, pWndOther, bMinimized);
}
}
~RaGE();
-- modified at 7:56 Wednesday 16th November, 2005
|
|
|
|
|
hi all, i am new to VC++. i want to write the out put of VC++ code in a notepad file, at a specific destination or alternative is that i want to write the output of a function in database.
kindly help me to achieve the task.
|
|
|
|
|
toufiq_raja wrote: hi all, i am new to VC++. i want to write the out put of VC++ code in a notepad file, at a specific destination
Your question is a little short on specifics, if you are using MFC then you can use the CFile class to write output to a text-file.
toufiq_raja wrote: alternative is that i want to write the output of a function in database.
What kind of database? SQL? Access? Oracle? MySql?
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
i am using the Oracle database. i need to write the out put in oracle database
|
|
|
|
|
that's very easy when you know how to use the standard library... (i consider you're using pure standard C++)
ofstream MyFile("C:\\myDir\\myFile.txt");
MyFile << "Hello world !!!";
MyFile.close();
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
sir i don't know the proper use of VC++.
i am a oracle developer. can u kindly send me an example of the code to write the out put in text file. what steps i have to follow.
which header files i need to include in the file.
regards
toufiq
|
|
|
|
|
ok, i already provided you a sample but if you don't know where to start, do this :
#include <iostream>
void main(void) {
std::ofstream MyFile("C:\\myDir\\myFile.txt");
MyFile << "Hello world !!!" << '\n';
int i = 5+4;
MyFile << "i = " << i << endl;
MyFile.close();
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 8:36 Thursday 17th November, 2005
|
|
|
|
|
i have run this code in VC++, but its not working
it contains errors
|
|
|
|
|
Hi to All
I am using PostgreSQL as my database. I am having one table called citizenphoto which contains cno and citizen photo as its fields. i have to insert images of citizens into that table through vc++.
For this i have derived that table to CRecordset object. and it is giving datatype for photo is CByteArray. when i am going to store image data of size more than 10K it is giving error as Data truncated. i have changed the size of that variable in DDX as 317000. But there is no use. Can anybody help me in this regard.
This will be so much helpful for me to go further.
Thanks in Advance.
|
|
|
|
|
I am working on a dialog based application where there are so many edit boxes.Now my requirement is that when the focus is in the first edit box & when i press the down arrow button,the focus(cursor) should shift to the next edit box(The tab order is already set in such a way that the focus goes to all the edit boxes one by one)..I had used the PreTranslateMessage() where i handled the VK_DOWN..Now here i have to write code for the shifting of cursor from one edit box to another edit box using SetWindowPos().I am not succeeded in completing this..So anyone plz help me!!
|
|
|
|
|
harish174 wrote: SetWindowPos().
Why SetWindowPos ? You do not want to move the edit box, only the focus, don'T you ?
harish174 wrote: should shift to the next edit box
Two possibilities here :
- the edit boxes are made at runtime, so you must have a pointer on them, so you may use:
pEditCtrl->SetFocus();
- the edit boxes all have ids.
GetDlgItem(IDC_NEXTEDITBOX)->SetFocus();
~RaGE();
|
|
|
|