|
You know, it all depends what you want it to do.
If you just want to populate it with data, then you can pass in that data to the dialog's constructor. And then in your OnInitDialog() method, populate the controls with data.
If you want to update the dialog with "live data", then something fancier is needed.
I am no MFC whiz! I've muddled through this MFC experience with the rest of the world... I am good at answering the questions, because I have made the same mistakes... and learned a lot along the way.
Just take your time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Hi,
I want to close the dialog in a certain time interval automatically after displaying it. Any ideas? Please excuse me if the question is very basic..
With Regards,
Sangeetha.
|
|
|
|
|
You can use of WM_TIMER and after a time send WM_CLOSE to your program.
|
|
|
|
|
Hi Whitesky,
Its working.. Thank you very much..
With Regards,
Sangeetha.
|
|
|
|
|
|
In Windows' Drawing Tool,there is a funtion that is we can select the discretioal part of the image.How can it realize?
Have I make a clear expression?;P
I appreciate your hint.
|
|
|
|
|
Do you want to select sections of an image and cut or other actions on the it?
|
|
|
|
|
Yes,I want to cut the section I select from the image.
|
|
|
|
|
Check this code:
BOOL CDialogDlg::OnInitDialog()
{
m_Image.Load("c:\\123.jpg");
}
void CDialogDlg::OnPaint()
{
CPaintDC dc(this);
m_Image.BitBlt(dc.m_hDC,0,0,800,600,0,0);
CDialog::OnPaint();
}
void CDialogDlg::OnBnClickedOk()
{
int x,y;
x=200;
y=200;
HDC dc;
HBITMAP hbit;
dc=CreateCompatibleDC(GetDC()->m_hDC);
hbit=CreateCompatibleBitmap(GetDC()->m_hDC,x,y);
SelectObject(dc,hbit);
BitBlt(dc,0,0,x,y,GetDC()->m_hDC,100,100,SRCCOPY);
CImage m_Image33;
m_Image33.Attach(hbit);
m_Image33.Save("d:\\22.bmp");
m_Image33.Detach();
DeleteDC(dc);
DeleteObject(hbit);
}
|
|
|
|
|
But the section was selected by the mouse,so the section is not a rect.
|
|
|
|
|
You want to select an area with mouse ok,its easy you have a click when you click mouse you must save start position with CPoint point;GetCursorPos(&point); that is x and y and when you free mouse its height,width thus you can select an area.
|
|
|
|
|
But the area is not a regular one...
|
|
|
|
|
I create a stream socket and start listening immediately.
But when I use "netstat -a" command in the cmd window,the socket's port would not be shown in the list.The sample code only like below:
CSocket listenSocket;
if(listenSocket.Create(0,SOCK_STREAM)==TRUE)
{
SOCKET port=listenSocket.m_hSocket;
if(listenSocket.Listen(10)==FALSE)
cout<<"Listen Failed!"<
|
|
|
|
|
Is your listenSocket variable going out of scope?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No,the socket is the member of the class
|
|
|
|
|
because you use listenSocket.Create(0,SOCK_STREAM) create listen socket, "0" means the server listen port is random number. this random number is also shown in the "netstat -a" list.
If you use listenSocket.Create(8000,SOCK_STREAM), the listen socket port will be fixed 8000. try "netstat -a" command you will find the listen port is 8000.
|
|
|
|
|
But,if I change to Create() and listen,the problem remain so.
Thanks
|
|
|
|
|
kcynic wrote: But,if I change to Create() and listen,the problem remain so.
Try something like Create(2500, SOCK_STREAM) and see if there's a socket listening on port 2500.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
But my real work is to create a listen socket and report the listening port to others then other client can to connect to the listening socket.
Thanks.
GOOD LUCK
|
|
|
|
|
I wrote a simple MFC multithreaded program using mutexes that was based on a sample MFC multithreaded program I found somewhere. I want to get time in the worker thread and then display it in the main dialog. I tried to pass the data between the threads using using global variables declared in a .h file included in both modules but I keep getting a link error, i.e., TimeThread.obj : error LNK2005: "long icount" (?icount@@3JA) already defined in clockDlg.obj. I am sure that there is a better way to pass data between threads than this way, anyway. I would appreciated some help as to the best way to pass data between threads.
Greg
|
|
|
|
|
Your linker problem is caused by the fact that the global variable "icount" is instantiated in every source file that includes the .h that declares it.
Try:
(In .h file)
<ref>
...
extern volatile long icount;
..
and in either of TimeThread.cpp or clockDlg.cpp (but not both)
<ref>
...
volatile long icount;
...
Without the "volatile" keyword, it doesn't matter how many mutexes you use, different threads may see different values depending on compiler optimisations.
It doesn't look to me as though you really need synchronisation with what you're doing here though, so why not just use RegisterWindowMessage(...) at startup to get a unique message ID & use PostMessage(...) from your worker thread to send the value to your dialog?
Regards,
T-Mac-Oz
|
|
|
|
|
Hi
I want to learn if i there is a list of defining .cpp files that mfc functions are defined.
I assume all the source code is in that directory C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc.
For example in that code:
ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
I want to see CWinApp::OnFileNew's implementation.
I tried to put breakpoint in that line strat to debug by F11. But i can not find the source code.
Is there another solution or where am i wrong?
For an example; How can i find the CWinApp::OnFileNew's implementation file?
I am looking for your answers.
Thanks.
|
|
|
|
|
I spend a significant amount of time looking into the ATL/MFC source code.
Thankfully, the Find in Files dialog saves used paths!
Ctrl-Shift-F, select the path in the dropdown (project, solution, PSDK includes, CRT source,
ATL/MFC source are the ones I use all the time), type in the Find What edit box if it's not there
already, and go.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
You could try adding an ID_FILE_NEW handler to your application class which calls the base class implementation & setting a breakpoint on it.
i.e.
<ref>
void C{YourProject}App::OnFileNew()
{
CWinApp::OnFileNew(); // Set breakpoint here
}
Regards,
T-Mac-Oz
|
|
|
|
|
Thank you
Both of your solutions work well.
Good works...
|
|
|
|