|
Hi,
How you get the coordinates (screen) (on Win32) of the icon/exe/shortcut that initiated an exe. I.e how can I obtain the position of the icon/mouse, on which i clicked/double clicked and my application started.
Thanks in advance.
|
|
|
|
|
Can you be more specific,please
|
|
|
|
|
I don't think this is possible. What exactly are you trying to do, popup your window next to the icon or something?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Steve Echols wrote: popup your window next to the icon or something?
yes that is true.
|
|
|
|
|
|
Please suggest me an article which helps me working with UDP.
I know working with TCP.
Thank you
KIRAN PINJARLA
|
|
|
|
|
See Here you can find the articles on UDP
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thank you _AnShUmAn_
KIRAN PINJARLA
|
|
|
|
|
|
Hi!
I am u using a Tree View control to get windows folder list. I am using IshellFolder Interface and PIDL to add folders to the list. The Problem is that I dont want some virtual folders to be added into the list.
Is there some way to determine whether the folder is virtual folder or some other special folder using its PIDL??
Thanks in advance!
|
|
|
|
|
See is this[^] good for you
|
|
|
|
|
Thx for the link! It was really helpful. I am facing a new problem now.
I am using SHGetDataFromIDList() function to determine the type of the PIDL variable.
Althought the fucntion returns NOERROR, I am not able to check the values of pv.dwDescriptionId structure. WHat I am trying to do is check dwDescriptionId and determine whether it is a FIXED drive or a removable.
here is my code
SHDESCRIPTIONID pv;<br />
HRESULT hres=SHGetDataFromIDList(pParentFolder,pidl,SHGDFIL_DESCRIPTIONID,&pv,sizeof(SHDESCRIPTIONID));<br />
if(hres==E_INVALIDARG) <br />
{<br />
MessageBox("ERROR","OK",MB_OK);<br />
}<br />
if(pv.dwDescriptionId & SHDID_COMPUTER_REMOVABLE)<br />
{<br />
MessageBox("REMOVABLE","OK",MB_OK);<br />
return;<br />
}
Plz help me!!
|
|
|
|
|
when we press the Show Desktop symbol in the quick lauch bar it minimizes the application
but i don't want to do so
So i m able to get the message of the first Show Desktop Click or (WindowsLogo + D)
and i do my processing accordingly i.e. minimize it in the system tray
i get the message in WM_SIZE IN THAT
void CProDlg::OnSize(UINT nType, int cx, int cy)
{
if(nType==SIZE_MINIMIZED)
{
//minimzed it in the system tray
}
}
but when we press it for the second time i.e.Show Desktop Click or (WindowsLogo + D) i m not able to
do the same as it was in the previouly i.e.i don't know how but my application gets popup and is displayed in an unwanted manner.
I am not able to find out which message is send to the dialogbox when the Show Desktop or Keyboard shortcut i.e. (Windows Logo+ D) for the second time.
One thing is clear that the process Shell_TrayWnd program sends message to all the application to minimze
val
/*MinAll*/ 415,
/*MaxAll*/ 416,
accordingly
static HWND hShellWnd = ::FindWindow(_T("Shell_TrayWnd"), NULL);
if(hShellWnd != NULL)
::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(415, 0), NULL);//for minimizing
::PostMessage(hShellWnd, WM_COMMAND, MAKELONG(416, 0), NULL);//for maximizing
This stuff will minimize all the window
Could u please find out the message so that i could remove the flaw.
Payal
Developer
|
|
|
|
|
Not sure I understand you too clearly, but you should be processing the WM_SYSCOMMAND message. This is what's sent to your application to tell it to minimize/restore. The WM_SIZE is only sent after the application has been resized.
|
|
|
|
|
if(pMsg->message==WM_SYSCOMMAND)
{
if(pMsg->wParam==SIZE_MINIMIZED||pMsg->lParam==SIZE_MINIMIZED)
{
OnMinimize();
pMsg->lParam=pMsg->wParam=0;
}
if(pMsg->wParam==SIZE_MAXIMIZED||pMsg->lParam==SIZE_MAXIMIZED)
{
OnMaximized();
pMsg->lParam=pMsg->wParam=0;
}
TRIED THIS THING BUT NOT WORKING
payal
|
|
|
|
|
Perhaps you should read the docs about the WM_SYSCOMMAND message. Where are those SIZE_MINIMIZED and SIZE_MAXIMIZED coming from? Infact, all you need to do is search the forums, I know for sure this topic has come up at least 3 times in the last week.
|
|
|
|
|
hi all,
In the OnPaint(...) event i am painting the Dialog as Black Color with every pixel PutPixel(...) with 15 * 15 (Horizontal and Vertical) Dots in entire Screen.
I want to create a Transparent EditControl when ever i am generate a LButton Click event, so that the Dots must be visible from the EditControl what i crated in LButtonDown(...) event.
i am giving the snippet of Code.
//===========================================================================
OnPaint(...) //Back ground color with Putpixel(...)
void CExpDlg::OnPaint()
{
if (IsIconic()) // not necessary wizard code
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else //My code starts here !!!!!!!!!!!!!!!!!!!!!
{
CPaintDC dc(this); // here the black color with Pixel --->
CRect Recto;
GetClientRect(&Recto);
CBrush bgBrush(BLACK_BRUSH);
dc.SelectObject(bgBrush);
dc.Rectangle(Recto);
for(int x = 0; x < Recto.Width(); x += 15)
{
for(int y = 0; y < Recto.Height(); y += 15)
{
dc.SetPixel(x, y, RGB(225, 225, 225));
}
}
CDialog::OnPaint();
} //My code Ends here !!!!!!!!!!!!!!!!!!!!!
}
//==========================================================================
//==========================================================================
second thing is generate the CEdit Control in LButton Event.
void CExpDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
ptr = new CEdit;
ptr->Create(WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL,CRect (point.x,point.y,point.x +100, point.y +20),this,NULL);
}
//===========================================================================
Now my doubt is The Edit box is created but the Dots that i have drawn in Onpaint must be Trasparent in the Dynamically Created EditBox is not visible.
because Transparent means the back side things must also be visible ????
please help me out.
Uday kiran
|
|
|
|
|
http://www.codeproject.com/editctrl/ctrltrans.asp
gO FOR THIS article a good one for the probs
payal
|
|
|
|
|
|
Hi Gurus,
Does using RegFlushKey automatically close the handle to a new registry key created using RegCreateKeyEx function. Or we have to use RegCloseKey if the handle needs to be closed?
Thanks
C++beginer
|
|
|
|
|
All RegFlushKey() does is write your changes to the registry rather than letting the OS's lazy flusher do the job. It does not close your handle, you have to do that yourself.
|
|
|
|
|
Ok. Thanks for clearing the doubt.
C++beginer
|
|
|
|
|
Hi,
I wanted to create a threaded dialog app however I couldn't find a simple example I could build on. I have now figured out a way to do it mainly based on this article (Unfortunaly you have to download windows speech to get it to run). So I am thinking of using it to create my first article here on code project.
My dialog consists of a start and stop button and an edit control.
The code for the start and stop buttons:
void CSimpleThreadDlg::OnBnClickedOk()<br />
{<br />
int i = 3;<br />
theApp.m_stop = false;<br />
theApp.m_pThread =AfxBeginThread(simThread,(LPVOID)i);<br />
m_start.EnableWindow(0);<br />
}<br />
<br />
void CSimpleThreadDlg::OnBnClickedStop()<br />
{<br />
theApp.m_stop = true;<br />
m_start.EnableWindow(1);<br />
}
And the code for my simple thread:
#include "stdafx.h"<br />
#include "SimpleThread.h"<br />
#include "thread.h"<br />
<br />
unsigned int simThread(LPVOID pParam)<br />
{<br />
unsigned int i = (unsigned int)pParam;<br />
CWnd* pEditControl=theApp.m_pMainWnd ->GetDlgItem (IDC_EDIT1);<br />
CString message;<br />
while(!theApp.m_stop)<br />
{<br />
pEditControl->GetWindowText(message);<br />
message.AppendFormat(_T("\r\nHello World #%i"),i);<br />
pEditControl->SetWindowText(message);<br />
Sleep(500);<br />
i++;<br />
if(i>10)<br />
{<br />
i = 0;<br />
<br />
pEditControl->SetWindowText("");<br />
}<br />
}<br />
PostQuitMessage(0);<br />
return 0;<br />
}
As you can see I disabled the Start button until the Stop button is pressed. If I don't do that it is possible to create multiple theads (Which is a bad thing since I believe it would overwrite the pointer - still leaving the existing thread running. The multiple threads also fight for the dialog.). When the dialog is closed in this situation the debugger reports memory leaks.
Now for my real app I want to kill the thread when the dialog closes...
CSimpleThreadDlg dlg;<br />
m_pMainWnd = &dlg;<br />
INT_PTR nResponse = dlg.DoModal();<br />
if (nResponse == IDOK)<br />
{<br />
}<br />
else if (nResponse == IDCANCEL)<br />
{<br />
}<br />
MSG msg;<br />
theApp.m_stop = true;
return FALSE;<br />
}
However this also has a memory leak, since the application closes before the second thread has a chance to execute...
So what is the correct way around this one? A simple Sleep(10); does the trick since it gives the other thread a chance to run and read m_stop.
Or I figured I could look at PeekMessage to see if the thread had sent the WM_QUIT message. However when debugging I looked at what peak message returned before setting m_stop and it equalled WM_QUIT. (I assumme it was the quit message for the dialog?) So the following loop to check if the thread has finished is not very useful.
<br />
do{ <br />
Sleep(10);<br />
PeekMessage(&msg, dlg, 0, 0, PM_NOREMOVE);<br />
}<br />
while(msg.message != WM_QUIT);
Another question - is the thread a UI thread or a worker thread?
Thanks for your help
Nick
|
|
|
|
|
Use CreateThread or _beginthreadex.
Then wait on the thread handle.
e.g.
theApp.m_pThread = _beginthreadex(...);
...
theApp.m_stop = true;
switch( WaitForSingleObject(theApp.m_pThread, 10000) ) {
case WAIT_TIMEOUT : TerminateThread(); break;
case WAIT_FAILED : ...; break;
case WAIT_OBJECT_0 : ...; break;
}
[EDIT]
From MSDN:
The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.
[/EDIT]
...cmk
Save the whales - collect the whole set ca
|
|
|
|
|
Hi,
Thanks for your help. You got me on the right track. Note AfxBeginThread calls CreateThread. Also that WaitForSingleOptject requires the handle of the thread as below....
switch( WaitForSingleObject(theApp.m_pThread->m_hThread, 10000) ) {<br />
case WAIT_TIMEOUT : TerminateThread(theApp.m_pThread->m_hThread,0); break;
Cheers
Nick
|
|
|
|