|
Yes, I had originally written that in my message, but took it out. At the time I was thinking there might be more code in this function that he had not included - like this could have been an "else if" with an "if" above it having a similar error. Otherwise this code would be called all the time since the handler processes all mouse events including mouse move.
I think the problem has to do with the window handle and I don't really like this call from a separate thread.
Soren Madsen
|
|
|
|
|
I just thought about something. You mention that the m_hWnd handle is defined, but do you actually assign it to the m_hWnd of your dialog object?
Soren Madsen
|
|
|
|
|
hi,
i'm still stuck with the dialog handle. i have posted the complete code. please i need help.
Regards
Jawad
|
|
|
|
|
jawadali477 wrote: the handle
HWND m_hWnd; is defined at beginning where the header files are included (i might be doing it wrong since i'm not good at programming with handle).
When do you define it? It has to be defined from the window handle AFTER it has been created (when using MFC, it means it should come after your window's OnInitDialog() has been called), otherwise it could be undefined.
FYI... your coding style seems more C-like than C++. Is your function global? Did you declare HWND m_hWnd a global variable? I hope you didn't do that because all MFC window based objects have a variable name m_hWnd.
|
|
|
|
|
hi,
i'm still stuck with the dialog handle. i have posted the complete code. please i need help.
Regards
Jawad
|
|
|
|
|
hi,
below is the complete code that i have developed. it builds fine and after debugging it shows two different windows, one containing image and other containing static boxes. but when i double click on the image window (which is my mouse event), values of (x,y) coordinates are not displayed in the static boxes (static boxes are in the separate window). please pardon my mistakes.
#include "stdafx.h"
#include "opencv01.h"
#include "opencv01Dlg.h"
#include "highgui.h"
#include "afxwin.h"
#include "cv.h"
#include "math.h"
#include<stdlib.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
void on_mouse( int evt, int x, int y, int flags, void* param );
HWND hwnd;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
Copencv01Dlg::Copencv01Dlg(CWnd* pParent )
: CDialog(Copencv01Dlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void Copencv01Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(Copencv01Dlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
END_MESSAGE_MAP()
BOOL Copencv01Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
SetIcon(m_hIcon, TRUE);
SetIcon(m_hIcon, FALSE);
AfxBeginThread(MyThreadProc, this);
return TRUE;
}
UINT Copencv01Dlg::MyThreadProc(LPVOID pParam)
{
Copencv01Dlg * me = (Copencv01Dlg *)pParam;
me->MyThreadProc();
return TRUE;
}
void Copencv01Dlg::MyThreadProc()
{
IplImage* img = cvLoadImage("box.png", CV_WINDOW_AUTOSIZE);
cvNamedWindow("map", 0);
cvShowImage("map", img);
cvSetMouseCallback("map", on_mouse, NULL);
cvWaitKey(0);
cvReleaseImage(&img);
cvDestroyWindow("map");
}
void Copencv01Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void Copencv01Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR Copencv01Dlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void on_mouse( int evt, int x, int y, int flags, void* param )
{
CString xaxis, yaxis;
if (evt == CV_EVENT_LBUTTONDBLCLK)
{
xaxis.Format(_T("%d"), x);
yaxis.Format(_T("%d"), y);
SetDlgItemText(hwnd, IDC_Blue, xaxis);
SetDlgItemText(hwnd, IDC_Green, yaxis);
}
}
Jawad
|
|
|
|
|
Hello
Env: Win7 64bits VS2010 Sp1Rel
When I maximized my MFC application, I'm unable to auto-unhide the taskbar. Sometimes, it flashes half a second and then stay hidden.
It's not a question of taskbar configuration. If I restore my app and maximize an other application (say Windows Explorer or Opera or any other ones ...), the taskbar auto-unhides correctly ...
Any clues why I got this strange behaviour ? Thanks for your Help
Thierry
|
|
|
|
|
I once had a problem like this when my application created a child window with the WS_POPUP style. It turns out that it should not have had that style set.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks for your answer but looks like the culprit is still to be found...
I have WS_POPUP at one place except, of course, in the Resource file for the Dialog templates. I remove the only reference of WS_POPUP but the problem still remains ...
Thierry
|
|
|
|
|
Hi
I just re-did my project moved things around got rid of some things i didn't
need everything works fine except for compiling my resource script
got rc2188
below is the output from the resource compiler
thanks in advance
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/atlconv.h(22) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/atlalloc.h(629) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/atlstr.h(16) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/atlbase.h(59) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afx.h(15) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afxver_.h(81) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afxver_.h(85) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afxv_w32.h(16) : error RC2188: C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afxver_.h(348) : warning RC4005: 'AFX_DATA' : redefinition
1>C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\include/afx.h(255) : warning RC4005: '_AFX_FUNCNAME' : redefinition
1>f:\HERC_CMD\Release\RCa05536(579) : fatal error RC1116: RC terminating after preprocessor errors
1>Build log was saved at "file://f:\HERC_CMD\Release\BuildLog.htm"
|
|
|
|
|
This usually means you have some unneeded #include statements in your source file, or some are out of order. Generally speaking you should not need to include everything within a resource file.
|
|
|
|
|
In other words look at the includes in resource file
thanks
|
|
|
|
|
Exactly what the compiler messages were telling you.
|
|
|
|
|
commneted out all the #includes
still getting the error
must be what I changed in the source don't know
|
|
|
|
|
the resource compiler reads uses resource.h had an errorous include
there thanks
|
|
|
|
|
Hi all,
Can anybody tell me how to sort a map based on the values.
e.g.
Map[key1] = box3;
Map[key2] = box1;
Map[key3] = box4;
Map[key4] = box2;
i want result like,
Map[key2] = box1;
Map[key4] = box2;
Map[key1] = box3;
Map[key3] = box4;
thanks in advance,
RKR
|
|
|
|
|
AFAIK, You can sort maps only by the Key element. I think that is the the point of having maps.
Your scenario might work out some way. but what if 2 different keys has the same values? how will you sort it?
Every new day is another chance to change your life.
|
|
|
|
|
NajaR12 wrote: Can anybody tell me how to sort a map based on the values.
Why do you want to do that?
Your desire suggests that you have misunderstood the purpose of a map.
The key is supposed to be unique and the value is identified by its corresponding key so you may write code such as in order to retrieve the "box" associated with the key :
Box& box = Map[key];
However, if your "boxes" are unique you may use them as keys, e.g.:
Map[box1] = key2;
Map[box2] = key4;
Map[box3] = key1;
Map[box4] = key3;
Consider using a std::list that is entry-sorted.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
a map isn't really the right container for this.
if you have pairs that need to be sorted, why not put them into a vector/list of std::pair<key,box> and sort that on box ?
|
|
|
|
|
hello guys... I have a listbox on my dialog. I am debugging my program and getting this error. Here is what I am trying
if(ListBox.GetCount() >= 1)
Now when I select ListCtrl.GetCount() and select Add Watch , it shows me the said error. Now although the problem is solved using following technique but what if I don't want to add unnecessary variables.
int count = ListBox.GetCount();
if(count >= 1)
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Please set your complier optimization option to “Disabled” and try
|
|
|
|
|
See here[^]; if the code is inlined then no function exists in the compiled version.
|
|
|
|
|
That variable would get optimised out in a release build anyway so dont worry about it.
|
|
|
|
|
I am using named pipes to transfer data between a DOS "C" program and Window MFC
program
In this scenrio the DOS program acts as the server while the Windows program is the Client
The Windows program send a string to the DOS program and the DOS program responds sending across 150 - 300 bytes
Speed is of otmost importance as this a ongoing conversation
I have chosen to use Named pipes
since I am releative newbie
I am wondering what the fastest method of IPC would be
Thanks in advance
|
|
|
|
|
Probably the fastest would be a shared memory pool... but are you sure you need that speed? A lot of times, people think they need the best of something when they really only need something that is good enough.
For example, even though shared memory would probably be the fastest option, it would probably not be easy to implement across multiple systems, your server and client would always have to be on the same machine (and by default, same OS), whereas if you used something more versatile like sockets, you could have your system work across different machines (or in the same one, no difference), different operating systems, different states, and even different countries.
So, make sure that you really need all that speed. For example, a phone conversation can be transmitted over sockets with no issue, but digitized IF (if you know what that means) could only go up to certain rates efficiently over a network.
|
|
|
|