|
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
|
|
|
|
|
If you have a hard coded lopp in your UI thread that stops it processing messages, you can add this code to the loop to allow other messages to be processed:
MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOYIELD | PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
Be careful as the cancel/ok buttons and the original button that set you loop going etc will be able to be used by the user. You need to set the dialog up in such cases that all commands you don;t want to be run during this long process are disabled.
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Hi,
i am looking for some api, or method
to check the current status of a service
and return a value to a program,
then if needs be i can start the service
via net start or relevant method
Thanks
|
|
|
|
|
I am not sure about your specific problem, but you may try using something like this to find your service:
<br />
SC_HANDLE hM = OpenSCManager(NULL,NULL,SC_MANAGER_ENUMERATE_SERVICE);<br />
if (hM)<br />
{<br />
ENUM_SERVICE_STATUS stat[1024];<br />
DWORD dwNeeded;<br />
DWORD dwRet;<br />
DWORD dwFirst = 0;<br />
if (EnumServicesStatus(hM,SERVICE_WIN32|SERVICE_DRIVER,SERVICE_STATE_ALL,stat,sizeof(stat),&dwNeeded,&dwRet,&dwFirst))<br />
{<br />
for (DWORD n=0;n<dwRet;n++)<br />
{<br />
char sz[256];<br />
sprintf(sz,"%s,%s,%i\n",stat[n].lpDisplayName,stat[n].lpServiceName,stat[n].ServiceStatus.dwCurrentState);<br />
OutputDebugString(sz);<br />
}<br />
}<br />
CloseServiceHandle(hM);<br />
}<br />
Or, if you are already in posession of the service handle,
<br />
BOOL QueryServiceStatus(<br />
SC_HANDLE hService,
LPSERVICE_STATUS lpServiceStatus
);<br />
Enjoy!
Maksim Lepikhin
www.softforpros.com
|
|
|
|
|
BOOL QueryServiceStatus(
SC_HANDLE hService,
LPSERVICE_STATUS lpServiceStatus
);
get its detailed information from MSDN!
|
|
|
|
|
I have a simple server that seems to be leaking handles.
The handle is to a registry key :
HKLM\SYSTEM\ControlSet001\Services\DnsCache\Parameters
In particular 1 handle (key) to this is leaked for each client connection.
The service is simple, it calls socket(AF_INET, SOCK_STREAM, IPPROTO_TCP), bind(), listen() then waits in a loop on accept().
Each accept() creates a thread that handles the connection.
All the thread does is some predefined sync send() and recv() calls then exits.
Everything is being closed correctly, thread, socket, ...
But each closed connection leaves another one of these handles around.
The handles don't appear to be cached, as i have tried leaving the service running with no conncetions for hours to see if they get 'cleaned up' - no joy.
Short of disabling the DNS Client service, does anyone have any ideas ?
[EDIT]
The handle is being created by SQLConnectA().
[/EDIT]
[EDIT_2]
I'm able to get rid of the leak by enabling connection pooling via :
::SQLSetEnvAttr(NULL, SQL_ATTR_CONNECTION_POOLING, (void*)SQL_CP_ONE_PER_DRIVER, 0);
[/EDIT_2]
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Is it possible to read binary data from a music or karaoke CD using the standard I/O functions in Win32? My purpose is to examine the data structure and learn more about them, possibly to try writing my own programs for managing content. Is this likely to require, instead, something at the device driver level?
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
Can't really answer your questions, but here's a pretty good FAQ that gives an overview, as well as links to more in-depth information:
http://www.cdrfaq.org/faq02.html#S2-43[^]
How do you move in a world of fog, That's always changing things?
Makes me wish that i could be a dog, When i see the price that you pay.
|
|
|
|
|
Excellent link, Josh - Thanks!
It looks like, if I'm going to pursue this, I'll need to install the DDK and learn to use it. Oh well, nothing easy is worth having...
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
What OS do you want compatiblity with? You can use SPTI in NT and use ASPI in 9x
SPTI
Have a look for opening CDRom drives using CreateFile, you can read sectors other than data using DeviceIoControl and IOCTL_CDROM_RAW_READ
ASPI
If you using ASPI then you can use many of the read commands defined in the SCSI 3 specification. READ_CD being your best bet.
Regards,
Ceri
|
|
|
|
|
Sounds promising - thanks!
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
I'm writing an app that when a certain event is received it brings itself forward to the top window on the z-order. However I cannot get this to happen on a win xp pro environment.
I tried this example that I found but this does not work
AttachThreadInput(<br />
GetWindowThreadProcessId(<br />
::GetForegroundWindow(),NULL),<br />
GetCurrentThreadId(),TRUE);<br />
<br />
SetForegroundWindow();<br />
SetFocus();
<br />
AttachThreadInput(<br />
GetWindowThreadProcessId(<br />
::GetForegroundWindow(),NULL),<br />
GetCurrentThreadId(),FALSE);
I've also tried this:
<br />
::AttachThreadInput(GetWindowThreadProcessId(hWnd, NULL) ,GetCurrentThreadId(), TRUE);<br />
::DefWindowProc(hWnd, WM_SYSCOMMAND, SC_RESTORE, NULL);<br />
::SetForegroundWindow(hWnd);<br />
::SetFocus(hWnd);<br />
::ShowWindow(hWnd, SW_SHOWNORMAL);<br />
::AttachThreadInput(GetWindowThreadProcessId(hWnd, NULL) ,GetCurrentThreadId(), FALSE);<br />
Still does not being itself forward.
Does anyone have any suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You could try setting it as the topmost window
::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
Though you will have to revoke this if you want other windows to move over it afterwards.
Ant.
|
|
|
|
|
OR replace HWND_TOPMOST with HWDTOP to move to the top without making it permanent.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|