|
Are you really sure you want to perform you action based on VK_RETURN? Perhaps you would be better off handling the LVN_ITEMACTIVATE message.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
I am already handling LVN_ITEMACTIVATE, which only seems to get sent by double-clicks. Thanks anyways though.
|
|
|
|
|
Aha! I was going to set out to prove you wrong about that, but now think I know what your problem is.
Your CListCtrl is in a dialog, right? As some of the other responses may have suggested, the dialog is eating your VK_RETURN messages. I suggest that you derive a class from CListCtrl and add a WM_GETDLGCODE handler something like this:
UINT CListCtrlEx::OnGetDlgCode()
{
const MSG *pMsg = (const MSG *)GetCurrentMessage()->lParam;
if (pMsg != NULL &&
pMsg->message == WM_KEYDOWN &&
pMsg->wParam == VK_RETURN) {
return DLGC_WANTMESSAGE;
}
return CListCtrl::OnGetDlgCode();
}
Assuming that you want the same thing to happen for double-clicks and the enter key, you should handle LVN_ITEMACTIVATE. If you want to do something different, then this change should get the WM_KEYDOWN/VK_RETURN to your list control.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
I'm not using MFC at all and My ListView control is in a mdi child window. So I can't use that code. I did mention I was not using mfc but I didn't mention what kind of parent window the list view was in because I didn't think it was important. Sorry about that.
btw Ryan Binns, you edited your answer to say "if you're using win32, just check your message loop". Do you think that answers my question? It doesn't. I admit I didn't search the forum for an answer before, but I have now. And it's not there.
|
|
|
|
|
Well, you may not be able to use the code, but you can still use the concept. You can subclass (in the Windows sense, not the C++ sense) the ListView control and handle the WM_GETDLGCODE message.
There may be more (seemingly) expedient ways to work around your problem, such as peeking the message loop or playing games with the default button, but I don't know of any ways more correct than handling WM_GETDLGCODE as I suggested.
--------
There are 10 types of people in this world. Those who know binary and those who don't.
|
|
|
|
|
I want to know whether the file is ms office file, pdf file, tiff file...etc.
I search and found example at microsoft.com. And I found out I can use StgOpenStorageEx to get the property of any files. but I'm still not success to get the type of the file yet.
Here is my code
<br />
....myfunction(){<br />
char filename[]="c:\\test.tiff";<br />
WCHAR wcFilename[1024];<br />
setlocale( LC_ALL, "" );<br />
int i = mbstowcs(wcFilename, &filename, strlen(filename));<br />
setlocale( LC_ALL, "C" );<br />
wcFilename[i] = 0;<br />
<br />
IStorage *pStorage = NULL;<br />
IPropertySetStorage *pPropSetStg = NULL;<br />
IPropertyStorage *pPropStg = NULL;<br />
HRESULT hr;<br />
<br />
hr = ::StgOpenStorageEx(wcFilename,STGM_READ,STGFMT_ANY,0,NULL,NULL,IID_IPropertySetStorage ,reinterpret_cast<void**>(&pPropSetStg));<br />
<br />
if(FAIL(hr))<br />
return<br />
<br />
hr = if(pPropSetStg == NULL)<br />
return;<br />
<br />
hr = pPropSetStg->Open(FMTID_SummaryInformation,STGM_READWRITE|STGM_SHARE_EXCLUSIVE,&pPropStg);<br />
the program has no error.. but pStorage = NULL so it never execute the last statement
hr= pProSetStg->Open.......
why is that? Is it StgOpenStorageEx(..) works for all kinds of file?
|
|
|
|
|
can anyone help me please...
I nned to know how to read the property of the non-MS Office files.
|
|
|
|
|
Ok, I posted this to Operating Systems/SysAdmin back on Jun.6.
Let's see if any C++ people can help me.
I'm trying to find a way to delete a user-defined EventLog file.
I create the reg keys (for example) :
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\My Log
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\My Log\File
and set ...\File = %SystemRoot%\system32\config\MyLog.evt
The file MyLog.evt is created by the EventLog monitor ... as expected.
Unfortunately it (services.exe i.e. EventLog monitor) maintains open references (4 it seems) to the file handle.
I guess it was a bit of wishfull thinking to hope that the handle would be closed when the reg key ...\My Log was deleted (and yes I make sure there are no sources left using the EventLog before I try to delete it).
My current solution is to queue a MoveFileEx(MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING) to a hardcoded filename in the temp directory.
Does anyone know of another way to get the ELM to release all references (close the handle) from C++ Win32 so that I don't need a reboot ?
I don't have .NET installed although I noticed it has a class that wraps access to EventLogs i.e. EventLog, and has a Delete method to delete a custom log file.
Does anyone know how the .NET EventLog.Delete works ?
...cmk
|
|
|
|
|
hello @all,
i have a CString, for example:
CString m="TSET";
but i need the invert (turn around) from this CString:
CString n="TEST";
how can i do this?
thank you very much.
sunny
|
|
|
|
|
n = m;<br />
n.MakeReverse();
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
thanks for reply.
it works great!!!!
THANKS!!!!
sunny
|
|
|
|
|
|
thanks for reply.
it works great!!!!
THANKS!!!!
sunny
|
|
|
|
|
Can I convert a CString varible to (char *) type?
For example:
void fun(char * str)
{
....
}
CString str;
fun(????str)
What should be added to before "str"?
|
|
|
|
|
|
|
Thank you!
|
|
|
|
|
When trying to find out this kind of thing, go to the help index and look at the class members. This provides a list of functions available for the class, saves a lot of time and you learn quite a bit in the process.
Elaine
The tigress is here
|
|
|
|
|
Hi. Im trying to get more control over a scroll bar from a ClistCtrl. I tried to use the "Flat Scroll Bars" from win SDK but they behave weird when i drag them. All the rest works fine, except from that weird behavior.
My code:
m_list=new CListCtrl();
m_list->Create(WS_BORDER | WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER, CRect(0,0,0,0),this,NULL);
::InitializeFlatSB(m_list->m_hWnd);
::FlatSB_ShowScrollBar(m_list->m_hWnd,SB_VERT,true);
::FlatSB_EnableScrollBar(m_list->m_hWnd,SB_BOTH,ESB_ENABLE_BOTH);
::FlatSB_SetScrollProp(m_list->m_hWnd,WSB_PROP_VSTYLE,FSB_FLAT_MODE,false);
::FlatSB_SetScrollProp(m_list->m_hWnd,WSB_PROP_CXVSCROLL,25,false);
Thanks in advance
|
|
|
|
|
My program needs to query a number of servers for data. I can do this by repeating the following:
for (each server)
{
Create socket
Connect socket to server
Close socket
}
What I want to do is use the same socket to connect to each server in turn so that I only have to create the socket once:
Create socket
for (each server)
{
Connect socket to server
Disconnect socket
}
Close socket
Is this possible? My socket is a CSocket.
Thanks
|
|
|
|
|
No. It is possible, however, to recreate a new socket and assign it to the socket handle in the same object.
Kuphryn
|
|
|
|
|
Sometimes I need to compare two boolean values, for example:
BOOL b1 = condition1();
BOOL b2 = condition2();
if (b1 == b2) // both TRUE or both FALSE
{
// something
}
else
{
// something else
}
Above code makes sense but actually I guess they are wrong, since BOOL's are actually INT's, while "false" is guaranteed to be "0", "true" is only guaranteed to be "non-zero" ---- in theory, it may or may not be "1", so even if b1 and b2 are both true, they don't necessarily equal to each other.
Although I can do this instead:
if ((b1 && b2) || (!b1 && !b2))
{
// something
}
else
{
// something else
}
This sure will work but looks ugly, my question is, how to compare two BOOL values in a way that the code works AND looks not ugly?
|
|
|
|
|
=[ Abin ]= wrote:
if ((b1 && b2) || (!b1 && !b2))
I don't think it looks that ugly, but you could always write a function to handle the comparison for you.
-Nick Parker
|
|
|
|
|
Maybe you can write your BOOL class and overload the operator "==".
YES, I am here.
|
|
|
|
|
(!b1) != (!b2)
looks better?
t!
|
|
|
|