|
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...
|
|
|
|
|
Have you tried F12?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for the handy tip-of-the-day!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
All of a sudden I cannot debug my applications. When I go to start, I get the above error.
I'm running VS2005SP1 with unmanged c++
I was able to run the other day, but today i cannot. This is code I'm trying to run (pretty simple)
--------------------------------------------------------
int main(int argc, char *argv[])
{
return 0;
}
---------------------------------------------------------------
Any thoughts
Tom
|
|
|
|
|
I don't know if it helps any, but a google search on "msdia80.dll"
yields several fixes for assorted problems related to that DLL.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did look there first. However, none of them matched my situation close enough. I'm trying not to have to re-install vs2005 to fix problem.
|
|
|
|
|
I did a repair install of VS2005 (1.5 hours), and that fixed the problem.
It appears some setting somewhere was corrupted.
Tom
|
|
|
|