|
|
You need to use SystemParametersInfo with the SPI_GETWORKAREA value: Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in virtual screen coordinates.
|
|
|
|
|
|
i use the code to mininmize all open windows
::PostMessage(FindWindow("Shell_TrayWnd",NULL)->GetSafeHwnd(),WM_COMMAND,MAKELONG(415,0),0);
::PostMessage(FindWindow("Shell_TrayWnd",NULL)->GetSafeHwnd(),WM_COMMAND,MAKELONG(416,0),0);
but the dialog box on which button to minimize all does not minmimize.
that is all open windows minimize except the dialog box containing button
.and i do coding on this button
thanks
Ashish Dogra
MCA
Noida
|
|
|
|
|
why not call ShowWindow(SW_MINIMIZE)after your ::PostMessage commands?
|
|
|
|
|
postmessage does not take one parameter
and i want to minimize all open windows not only one ,
thanks for your reply.
Ashish Dogra
MCA
Noida
|
|
|
|
|
You can accomplish this in three calls then...the PostMessage commands you have (will minimize all windows except the dialog calling it).
Then use ShowWindow(SW_MINIMIZE) to minimize the current window.
|
|
|
|
|
thanks
but it does not minimize all windows it minimize only itself and one window.
and also tell me if button is on third dialog then last two dialog are not minimized
Ashish Dogra
MCA
Noida
|
|
|
|
|
ashish dogra wrote: but the dialog box on which button to minimize all does not minmimize.
that is all open windows minimize except the dialog box containing button
Doesn't this mean that the only window not minimized is the one with the "button" on it? At this point in your program, you only have 1 window left open? If so, call the ShowWindow now and this one window will minimize.
|
|
|
|
|
Why not something as simple as:
keybd_event(VK_LWIN, 0, 0, 0);
keybd_event(77, 0, 0, 0);
keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0);
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
That's a terrible technique. You need to check if applications have a systembox and, if so, if the minimize button is visible. Otherwise you are risking sending an application a message it specifically chooses not to handle, often triggering unexpected states in the code.
earl
|
|
|
|
|
ashish dogra wrote: .and i do coding on this button
call PostMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MINIMIZE,0);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
i have the folowing function that doesn't work:
i get an error like: "MultiByteToWideChar' : cannot convert parameter 5 from 'char *' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"
void CMina_sView::OnListenCom1()
{
CSerial serial;
LONG lLastError = ERROR_SUCCESS;
TCHAR tszMsg[200];
lLastError = serial.Open(_T("COM5"),0,0,false);
lLastError = serial.Setup(CSerial::EBaud9600,CSerial::EData8,CSerial::EParNone,CSerial::EStop1);
lLastError = serial.SetMask(CSerial::EEventBreak |
CSerial::EEventCTS |
CSerial::EEventDSR |
CSerial::EEventError |
CSerial::EEventRing |
CSerial::EEventRLSD |
CSerial::EEventRecv);
lLastError = serial.SetupReadTimeouts(CSerial::EReadTimeoutNonblocking);
// Wait for an event
lLastError = serial.WaitEvent();
// Save event
const CSerial::EEvent eEvent = serial.GetEventType();
// Handle ring event
// Handle data receive event
if (eEvent & CSerial::EEventRecv)
{
// Read data, until there is nothing left
DWORD dwBytesRead ;
char szBuffer[101];
do
{
// Read data from the COM-port
lLastError = serial.Read(szBuffer,sizeof(szBuffer)-1,&dwBytesRead);
// Finalize the data, so it is a valid string
szBuffer[dwBytesRead] = '\0';
// Convert the ANSI data to Unicode
LPTSTR lpszBuffer = LPTSTR(_alloca((dwBytesRead+1)*sizeof(TCHAR)));
MultiByteToWideChar(CP_ACP, 0, szBuffer, strlen(szBuffer), lpszBuffer, sizeof(lpszBuffer)+1);
m_pSet->AddNew();
m_pSet->m_Nume=szBuffer;
m_pSet->m_Serie="asfasdvce";
CTime time = CTime::GetCurrentTime();
m_pSet->m_Data=time;
UpdateData(TRUE);
if (m_pSet->CanUpdate())
m_pSet->Update();
m_pSet->Requery();
UpdateData(FALSE);
m_pSet->Close();
m_pSet->Open();
Invalidate();
UpdateWindow();
}
while (dwBytesRead == sizeof(szBuffer)-1);
}
// Close the port again
serial.Close();
}
|
|
|
|
|
tanarnelinistit wrote: // Convert the ANSI data to Unicode
LPTSTR lpszBuffer = LPTSTR(_alloca((dwBytesRead+1)*sizeof(TCHAR)));
MultiByteToWideChar(CP_ACP, 0, szBuffer, strlen(szBuffer), lpszBuffer, sizeof(lpszBuffer)+1);
I think you need to use WCHAR instead of LPTSTR and for sizeof(TCHAR) use sizeof(WCHAR)
hope this helps
Jetli
Constant Thing In World Is Change.
|
|
|
|
|
tanarnelinistit wrote: LPTSTR lpszBuffer = LPTSTR(_alloca((dwBytesRead+1)*sizeof(TCHAR)));
MultiByteToWideChar(CP_ACP, 0, szBuffer, strlen(szBuffer), lpszBuffer, sizeof(lpszBuffer)+1);
Shouldn't that be:
LPWSTR lpszBuffer = reinterpret_cast<LPWSTR>(_alloca(dwBytesRead+1)*sizeof(WCHAR));
Personally, I wouldn't use _alloca, I'd use something like
WCHAR wszBuffer[102]; // If you really must use magic numbers...
Steve S
Developer for hire
|
|
|
|
|
Hello,
replace your code:
<br />
LPTSTR lpszBuffer = LPTSTR(_alloca((dwBytesRead+1)*sizeof(TCHAR)));<br />
with this code:
<br />
TCHAR* unicode_string;<br />
unicode_string = (TCHAR*)calloc(dwBytesRead+1, sizeof(TCHAR));<br />
maybe helps?
or try instead LPTSTR to use LPWSTR???
regards
break;
|
|
|
|
|
maybe u haven't define _UNICODE. Hence
LPTSTR lpszBuffer is equavalent to char* lpszBuffer.
so
Either define _UNICODE
or
change LPTSTR lpszBuffer to wchar_t* lpszBuffer;
nave
|
|
|
|
|
Thanks for the tips. Now i don't get the error any more, but still my string hasn't got the correct value. I should get something like: "FFFFAAAAA121312C" and I get "F", only F.
|
|
|
|
|
tanarnelinistit wrote: ...my string hasn't got the correct value. I should get something like: "FFFFAAAAA121312C" and I get "F", only F.
How are you verifying this?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I have a program that came with the tool that connects to the COM, and I know the value I should get because that's what that prg gives me.
|
|
|
|
|
i think this is because the IDE dosen't show the unicode strings... change the IDE settings as below..
take tool->options menu.
now take the debug tab in the Options dialog displayed.
U can find a check box saying "Display unicode strings". Tick that check box.
now run the application with a break point set in the next line of "MultiByteToWideChar(..)" function. Check the value in the variable when breakpoint reaches there
nave
|
|
|
|
|
Hey All,
I am implementing the Date & Time Picker through MFC. I placed it on my dialog and assigned a variable to it...CDateTimeCtrl m_DateTime;
I also added the event handler OnDtnCloseupDatetimepicker, and it works fine as long as I don't try to pick a date before Jan 1, 1970. If I pick a date before then, I get a Debug Assertion error on atltime.inl, Line 167, Expression: m_time != -1.
I have never seen this before....
Here is the code that I have in the closeup function...
void Measure1::OnDtnCloseupDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult)
{
m_DateTime.GetTime(time);
int mnth = time.GetMonth();
switch(mnth)
{
case 1: Month = "January";
break;
case 2: Month = "February";
break;
case 3: Month = "March";
break;
case 4: Month = "April";
break;
case 5: Month = "May";
break;
case 6: Month = "June";
break;
case 7: Month = "July";
break;
case 8: Month = "August";
break;
case 9: Month = "September";
break;
case 10: Month = "October";
break;
case 11: Month = "November";
break;
case 12: Month = "December";
break;
}
Day = time.GetDay();
Year = time.GetYear();
*pResult = 0;
}
Thanks in advance....
|
|
|
|
|
I would guess that your time is a CTime. If so, the CTime object date limits are 1/1/1970 to 1/18/2038 (in VC6) and 1/1/1970 to 12/31/3000 in VC8 (2005).
You could use COleDateTime for your time variable instead and that should solve your problem - it will handle dates from 1/1/100 to 12/31/9999.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
<kmedcalf@ev1.net>
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
goodoljosh1980 wrote: m_DateTime.GetTime(time);
Is 'time' a CTime object? If it is, it's limited to January 1st, 1970 to January 18th, 2038. Try a COleDateTime object instead, it has a range of January 1st, 100 to December 31st, 9999.
- Dy
|
|
|
|
|
I have an application with plenty of windows. Some of them a re CView subclasses others are controls etc.
My views usually track the mouse using the mouse events like the CWnd::OnMouseMove messages (which I have properly mapped etc).
Reading the OnMouseMove help says that:
'The framework calls this member function when the mouse cursor moves. If the mouse is not captured, the WM_MOUSEMOVE message is received by the CWnd object beneath the mouse cursor; otherwise, the message goes to the window that has captured the mouse.'
I would like to know at a given point where the mouse is, or actually if the recepient of the next mouse input message is the current CWnd or not (i.e. is it still beneath the cursor?).
I 'd like to write code like
MyClass::OnMouseMove(....)<br />
{<br />
DoMyInitialAction(); <br />
<br />
if( MouseInputStillOnMe() ) <br />
DoSomeOtherAction(....); <br />
}
If my DoMyInitialAction creates a new view it is likely that the next mouse input message will go on that one. I do not want to capture the mouse and receive any event related to it just in case that the DoMyInitialAction
does that (It's a black box. I do not know what will do).
Thus is it possible to write a MouseInputStillOnMe() query which will not post any message to my message queues but will tell me that under the current circumanstances I 'll receive the next mouse input message?
I assume that I can use the CWnd *CWnd::GetCapture( ) to find if another CWnd in my thread receives the mouse events but this does not answer if my window is still the one beneath the cursor. How do I found if it is?
Thanks a lot for any help....
Dimitris...more you ask, more you learn
|
|
|
|