|
SetForegroundWindow or BringWindowToTop .
Nibu thomas
Software Developer
|
|
|
|
|
vvbkumar wrote: how do i change the focus to current dialog ?
What is the current dialog exactly ? And are you using modal or modeless dialogs (do you call DoModal) ? If you are using modal dialogs, then you cannot switch the focus between dialogs, you have to look for modeless dialogs instead.
|
|
|
|
|
How to write and read an object of user defined class say ABC into file.
|
|
|
|
|
Depends what you are using. Are you using the MFC's ? If yes you can look at serialization. And please, be more specific when you ask a question.
|
|
|
|
|
Hi anilksingh,
I used to write objects of my class, in the C way, using "fwrite". Here is the code snippet:
Regards,
Sarvan AL
class Student<br />
{<br />
int regno;<br />
char name[30] ;<br />
public:<br />
Student() <br />
{ <br />
regno = 0; <br />
strcpy(name, "NULL") ;<br />
} <br />
Student(int rno, char *tname)<br />
{<br />
regno = rno ;<br />
strcpy(name, tname) ;<br />
}<br />
void Display()<br />
{<br />
cout<<"Regno: " << rno << endl ;<br />
cout<<"Name: " << name << endl ;<br />
}<br />
} ;<br />
<br />
main()<br />
{<br />
FILE *fp = fopen("Test.dat", "wb") ;<br />
Student s1(1, "Robert"), s2(2, "Smith") ;<br />
<br />
fwrite(&s1, sizeof(Student), 1, fp) ;<br />
fwrite(&s2, sizeof(Student), 1, fp) ;<br />
<br />
fclose(fp) ;<br />
<br />
Student t ;<br />
<br />
fp = fopen("Test.dat", "rb") ;<br />
<br />
fread(&t, sizeof(Student), 1, fp) ;<br />
t.Dispaly() ;<br />
<br />
fread(&t, sizeof(Student), 1, fp) ;<br />
t.Dispaly() ;<br />
<br />
fclose(fp) ;<br />
<br />
}
|
|
|
|
|
How to write and read an object of user defined class say ABC into file.
|
|
|
|
|
why do you ask this on many forums ?
do you want to serialize your objects in Managed C++ or unManaged C++ way ?!
|
|
|
|
|
Dear all,
I trid to use SetWindowLong to replace the original Window Process.
But my custom wndProc can not recive the all CM_ begining message.
why? andbody could give me a hand?
thank you very much.
Bill Lin
|
|
|
|
|
CM_ ...? I haven't hearded about such a message. Can u plz tell me ,what type of message is that?
nave
|
|
|
|
|
sorry, CM_ is not default message of vc++. that is Delphi's. but my purpose is I want to recive MouseLeave and MouseEnter events.
Bill Lin
|
|
|
|
|
Take a look at TrackMouseEvent .
Nibu thomas
Software Developer
|
|
|
|
|
thank you very much. I think that's what I want.
|
|
|
|
|
It's related to device drivers.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
hey,guy,I'm confused when using dtpicker Activex control.dtpicker->GetYear()returns a VARIANT ,I write some words like below:
CString m_String;
m_String.Format("%d",m_dtpicker.GetYear().date);
but It returns some unknown interger,what's wrong with my code,how to use dtpicker get and put value?
Thanks.
Lee
|
|
|
|
|
Dear Experts,
I test such code in Visual C++ 6.0 as following:
#include <stdio.h>
#include <time.h>
int main()
{
char c0;
char c1;
char c2;
printf("%p\n%p\n%p\n",&c0,&c1,&c2);
return 0;
}
In "DEBUG" build mode without optimizationm, the output is :
0012FF7C
0012FF78
0012FF74
In "RELEASE" build mode without optimization, the output is :
0012FF7C
0012FF78
0012FF74
In "RELEASE" build mode with "Maxmize Speed" optimization, the output is:
0012FF7D
0012FF7E
0012FF7F
So, as above, in stack, there are redundant bytes in these "char" variables.
Why? Why Visual C++ compiler insert redundant bytes into stack?
Your Sincerely
REMY
|
|
|
|
|
I'm not sure but I'd guess it has something to do with char-to-int promotion.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
1) User defined message is declared as Follows [ Defined in Both Sender and Receiver ]
#define TEST_MSG WM_USER + 1
2) The Message data Structure Declared [ In both The Application ]
class msgData<br />
{<br />
public:<br />
int msgNo;<br />
CString data;<br />
};
3) Window1 in App1 Sending the Message
void CTesterDlg::OnButton1() <br />
{<br />
HWND hw = ::FindWindow(0, "TestDCLeak") ;<br />
msgData * data = new msgData();<br />
data->data = "Sample Message" ;<br />
data->msgNo = 20 ;<br />
::SendMessage(hw, TEST_MSG, (WPARAM) data , 0 );<br />
}
4) The Following Message Map is Added in the AFX_MSG_MAP Section of the App2:
ON_MESSAGE (TEST_MSG, OnTest )
5) The Linkage b/t the Handler and the Message is Done as Follows [ In App 2] :
afx_msg LRESULT OnTest(WPARAM wParam, LPARAM lParam);
6) Window 2 in App2 Receiving the Message
LRESULT CTestDCLeakDlg::OnTest(WPARAM wParam, LPARAM lParam)<br />
{<br />
msgData * theData = (msgData * ) wParam ;<br />
AfxMessageBox(theData->data);<br />
return 0;<br />
}
* I can Find the App2 Message is Handler is Invoked & the pointer thedata in App2 is Equal to pointer
data in App1.
* But, I can't Able the get the data packed in App1, inside the App2..
Can Anybody Please Explain why this is Happened? What Correction I should take in Code?
|
|
|
|
|
These are 2 different applications ?
Then, forget about it because they don't share the same address space. You won't be able to share memory between two applications.
You'll need to go for another way to share your data. Either pipes, memory mapped files (I only used this one), or even files.
|
|
|
|
|
Cedric Moonen wrote: memory mapped files
Can you Please Explain the Technique?
|
|
|
|
|
It is a little bit complicated to explain in details but basically it is memory that can be shared between several applications. This memory 'pool' has a name that identifies it, then, given this name, you can get a pointer to the start address of the memory pool and from there you can retrieve data.
Take a look here[^] for a start but it will require some time to implement.
|
|
|
|
|
Instead of sending the user defined message(TEST_MSG), Use WM_COPYDATA Message
nave
|
|
|
|
|
Thanks, I will Try..
-- modified at 3:39 Friday 7th April, 2006
|
|
|
|
|
Yes it's true, you can use WM_COPYDATA also (I forgot about that one). But be carefull because you have to take care of what you send. Take a look at the MSDN[^] for more details.
|
|
|
|
|
Hello,
i m s/w professional mainly in C,C++. but now i want to learn VC++ and i want so start with develop a GUI in VC++.
so pls guide me or suggest me. "how to start?"
kedia
|
|
|
|
|
Go to the Site www.FunctionX.com
It has a very good VC++ Tutorials for the Beginers.. [ You have to click the VC++ Link inside it]
|
|
|
|