|
o nm, it was just a stupid clash of varibles, i was using "Mouse" for my point. So as to help others, i will post what i did
POINT MousePos;
GetCursorPos(&MousePos);
PopupMenu1->Popup(MousePos.x,MousePos.y);
Remember that this is for borland cpp builder and not vcpp, although it is basically the same...
ty
---------------------
And Like The Wind Our Hero Vanishes Off Into The Distance...
|
|
|
|
|
Just a stylistic point: if you're creating a popup menu in response to a mouse message, you typically want to create the menu where the pointer was when the mouse was clicked, not where it is now. You get this co-ordinate in the message's lParam (see for example WM_LBUTTONDOWN ). I'm not familiar with Borland C++ Builder, so I don't know how messages are processed in your application.
The exception to this is if you're handling a system tray icon notification message, where you don't get the parameters to the original message (and hence the location of the click).
You should use the message's cursor position because the user may have moved the mouse since clicking. If your application, or the system, is busy, this may cause the menu to appear somewhere different, which confuses the user.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi,
I want to implement the toolbar button to receive the dropped contents.
I am using COleDropTarget and I have registered that using m_DropTarget.Register(this). It works for a window, List control...But It doesn't work incase of toolbar buttons. Could anyone knows how to implement this?
Regards
Neha
|
|
|
|
|
I got lot of workspaces to be build... Is there any way i could build it from the command line, so that i can write a .bat file... There seems to be no make file or .mak file in my project directory
Thanx.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
You can run msdev from the command line and get it to do a compile and then exit. I can't remember what the command-line switch is, but you should be able to find it on MSDN. You just pass it your project file and the configuration you want to build, and it takes care of the rest.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanx a lot, just needed a pointer.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
It's /make . MSDEV.COM also understands the /? option to provide command-line help.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Go to C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\Common\MSDev98\Bin and type msdev /? at the command prompt.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
thanx for the help, i got that part figured it out.. Now i got one more problem..
If in the batch file i am compiling more than 1 project... i want to stop the build if there is any error in the first build.
so i tried it like this.
msdev build etc.
if errorlevel == -1 goto processerror.
but now it goes to processerror in both cases (build with and without errors)
(yeah i got one warning in the build, i want to build it anyway)
is there any way i could stop the build process if there is an "error" in the build.
or am i asking too much
thanx.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Mr.Prakash wrote:
if errorlevel == -1 goto processerror.
You should be comparing errorlevel to 2 instead.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
humm, I will try that... but then the condition was satisfiing when i was comparing it with -1 then if i compare with 2 will never satisfy.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Then you need to compare against 0, which is the only non-error value. For example:
msdev.exe ...
if not errorlevel 0 goto processerror
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
It works fine, the above code when there is any compilation error. But if there is no compilation error of the .cpp files but if there is an error in compilation of the resource then the comparison fails and it goes forward as if the build was success
Thanx for the help anyways.
MSN Messenger.
prakashnadar@msn.com
Tip of the day of visual C++ IDE.
"We use it before you do! Visual C++ was developed using Visual C++"
|
|
|
|
|
Using different scenarios, you might try printing the value of errorlevel at the end of each compilation. That way you'll know what conditions produce what results.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi,everyone.
Under WindowsXP,users can hide or show an application tray icon by customizing tray notification,but now i want to implement this in my application. i have tried some methods(such as using sysinternal's utilites - Regmon and Filemon ) to find how Windows Shell handles this,but the results disappointed me.
so can anyone know to do this ? use some undocumented windows shell api?
Thanks a lot!
|
|
|
|
|
Hello,
I've written a card game with all the bells and whistles, but I still have some learning to do. The problem is when I programmed it so that you see your first card, get a sound effect, a pause by the computer, then your next card, etc. Instead, you get five straight sound effects, a ton of pause, then all five cards pop up at once.
m_box01.SetBitmap(face[y]); soundfx(3); Sleep(250);
somewhere inbetween calling my soundfx subroutine and the Sleep function, I need to call something that will refresh the screen and show the card I displayed with SetBitmap. Something like an UpdateData or DoDataExchange kind of thing. I've made guesses until I'm blue in the face. Can anyone help?
thanks!
Dimenser
|
|
|
|
|
Call Invalidate() and then UpdateWindow .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks.
UpdateWindow(); all by itself does what I wanted it to do... most of the time. I can't figure out any rhyme or reason but sometimes it doesn't work at all later in the program, even if I use Invalidate();
Because the program is so graphics intensive (transparent bitmaps on top of full screen bitmaps), Invalidate causes the screen to do a slow flash that is really unimpressive.
I will fiddle with it more and see if Invalidate can be used to redraw one bitmap only or the such.
thanks again, you got me on the right track.
Dimenser
|
|
|
|
|
while i try to use atciveX control CMSCOMM.ocx with VC++6.0, i find some trouble problem.
1. must to use
'a &= 0x7F;'
because that the code received have a wrong format,but it's right after i use 'a &= 0x7F;'...
2. some code can't be received sometimes.
such as: 'thanks', only can receive 'anks'
the code as below:
void CMainFrame::OnOnCommMscomm()
{
VARIANT vat_input;
COleSafeArray oleSA_input;
LONG length, i;
BYTE data[1024] = {0};
CString msg;
char a = 0;
INT nEvent = m_Comm.GetCommEvent();
if (nEvent == 2 ) //|| nEvent == 3 || nEvent == 6)
{
oleSA_input.Clear();
memset(&vat_input, 0, sizeof(VARIANT));
vat_input = m_Comm.GetInput();
m_Comm.SetInBufferCount(0);
oleSA_input = vat_input;
length = oleSA_input.GetOneDimSize();
for (i=0; i<length; i++)
="" {
="" olesa_input.getelement(&i,="" data+i);
=""
="" a="*(char" *)(data+i);
="" &="0x7F;
" msg.format("%c",="" a);
="" m_strincomstring="" +="msg;
" }
="" }
="" m_com_edit.displayrecedatum(m_strincomstring);
="" cuartdoc*="" pdocu="(CUARTDoc*)(this-">GetActiveDocument());
if (pDocu->m_CurrentStatus == STATUS_START)
{
pDocu->DoAnalyseData((LPTSTR)(LPCTSTR)m_strINComstring);
}
m_strINComstring.Empty();
}
else if (nEvent>1000)
{
if (m_Comm.GetPortOpen())
{
m_Comm.SetPortOpen(FALSE);
}
m_Comm.SetPortOpen(TRUE);
}
}
and the setting as below:
m_Comm.SetCommPort(pComSet->ComPort);
m_Comm.SetInBufferSize(4096);
m_Comm.SetInputMode(1);
m_Comm.SetInputLen(0);
m_Comm.SetOutBufferSize(4096);
m_Comm.SetRThreshold(1);
m_Comm.SetSThreshold(0);
m_Comm.SetEOFEnable(TRUE);
m_Comm.SetDTREnable(TRUE);
m_Comm.SetHandshaking(0);
m_Comm.SetNullDiscard(FALSE);
m_Comm.SetRTSEnable(FALSE);
m_Comm.SetSettings(_T("115200, n, 8, 1"));
who can helpp me!! thanks!!!
|
|
|
|
|
I haven't done much straight Win32 programming (mostly just use MFC), so learning how to create a custom Win32 control has been a challenge. I've created a static control, I'm drawing it using WM_DRAWITEM, and capturing mouse click events using STN_CLICKED. I'm now stuck on finding the mouse cursor's position relative to my control. I'm capturing the WM_MOUSEMOVE event and saving the mouse position, and then using ClientToScreen and ScreenToClient to convert the mouse position to a relative coordinate. That works, but for some reason WM_MOUSEMOVE isn't sent when the mouse is over my control; everywhere else, it is. I'm guessing that the mouse event is being sent somewhere else, but I can't figure out where; can you help me?
|
|
|
|
|
Have you specified the SS_NOTIFY style when creating the window?
|
|
|
|
|
Yes, that's how I'm capturing the STN_CLICKED event.
|
|
|
|
|
All,
I posted this message on the following board, but since this area gets more traffic, and also since I don't believe the problem is necessarily related to the serial code, I will repost it here:
http://www.codeproject.com/system/serial.asp?target=serial
Ramon,
I'm guessing that you might be the only one that might be able to answer this. I have had great success incorporating your sample code into my project. I am controlling an external device that I write to once a second to start it performing a series of A/D conversions. When it is done it sends the data back, and the reader thread notifies my dialog box that there is data via the PostMessage routine. So far so good.
Because I had a need to send data to the external device every second, I created a second writer thread, similar to the reader thread. I essentially copied the code and changed names and such and I now bring up both threads. My main dialog window is still the destination for the messages that get sent by the PostMessage routine.
Here is my problem. The application that I incorporated your code into has a hard coded loop in the main DialogProc routine. This is perhaps not good programming practice as it hangs the code from processing any windows messages, including the messages from PostMessage that indicate that there is serial data to be read. What happens is then that I miss the serial data. What I need to be able to do is run that main loop AND process the messages that indicate there is serial data coming in.
I tried to solve this by creating a new window within the writer thread that has it's own doalog processor for windows messages. Here is that code:
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) MyWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = "MyWindowClass";
returned_class_atom = RegisterClass(&wc);
if (!returned_class_atom)
{
last_err = GetLastError();
}
agilent_receiver = CreateWindow("MyWindowClass",
"Nothing",
WS_MAXIMIZE,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
HWND_MESSAGE,
NULL,
NULL,
lpvoid_null);
if (agilent_receiver == NULL)
{
debug_stop = 1;
last_err = GetLastError();
}
This code all runs fine, and when I run it in debug the call to CreateWindow results in a series of 7 messages being sent to the message processing routine MyWindowProc which is the routine specified in the call to RegisterClass when the newly created class is registered. The window handle agilent_receiver comes back with a good value.
I then thought that I could simply reroute the notifications by changing the CSerialWnd::OnEvent routine as follows:
void CSerialWnd::OnEvent (EEvent eEvent, EError eError)
{
int a,b;
if (PostMessage(agilent_receiver,m_nComMsg,MAKEWPARAM(eEvent,eError),LPARAM(m_lParam)))
a=b;
else
b=a;
}
The funny thing here is that when I put in agilent_receiver as the destination instead of your value of m_hwndDest, I don't receive the notifications in my message handler. The PostMessage call appears to work as it returns a non-zero value.
I don't think it has anything to do with the threads, because your code sends the windows messages from the reader thread to the main GUI window message handler, which is in a different thread. I am just trying to send those same windows messages to a new window created in the writer thread.
Any ideas,
Robert
|
|
|
|
|
I am not fully sure what you are trying to achieve but when posting messages between threads you really should use PostThreadMessage()
PostThreadMessage posts messages to the queue of the specified thread without waiting.
Ant.
|
|
|
|
|
Antony,
Thanks for the tip. I switched the call to PostThreadMessage and in my thread I now periodically check for message arrival with PeekMessage and am seeing them there.
Robert
|
|
|
|