|
I use miriam fixed in .NET and lucida console in VS 6. They are harder to read than courier new, but the lines are closer together so I get more on the screen at a time.
|
|
|
|
|
Hmm.. As usual something that has first appeared obvious to me.. isn't.
I am using a class that sends the view a User Defined Message to notify it of some events that are taking place.
However after setting up the command handlers for the view I realized that the view was not recieving or processing the message.. so I decided to setup a test message.. and it is not working either.. so I must be doing something wrong.. and I just can't figure it out. I setup the test message handler as such.
afx_msg void OnTestMsg(WPARAM wParam, LPARAM lParam);
ON_COMMAND(WM_TESTMSG, OnTestMsg)
void CMyView::OnTestMsg(WPARAM wParam, LPARAM lParam)
{
TRACE("Test Message");
}
defined message in view header as such
#define WM_TESTMSG WM_USER + 5
Created a command ID with the following
SendMessage(WM_TESTMSG);
SendMessage(WM_TESTMSG,0,0);
::SendMessage(GetSafeHwnd(), WM_TESTMSG);
::SendMessage(GetSafeHwnd(), WM_TESTMSG,0,0);
but the message function is never fired..
Anybody see anything obvious that I am doing wrong.
Thank you.
|
|
|
|
|
ON_COMMAND is not used for handling user defined messages. For user define messages you should rather use the macro ON_MESSAGE .
In addition, the handler function for user defined messages, or that should be passed for ON_MESSAGE macro takes the follwing form:
LRESULT OnTestMsg(WPARAM wParam, LPARAM lParam);
Therefore, your code should be like this
#define WM_TESTMSG WM_USER + 5
.
afx_msg LRESULT OnTestMsg(WPARAM wParam, LPARAM lParam);
ON_MESSAGE(WM_TESTMSG, OnTestMsg)
.
.
.
LRESULT CMyView::OnTestMsg(WPARAM wParam, LPARAM lParam)
{
TRACE("Test Message");
}
.
.
.
SendMessage(WM_TESTMSG);
|
|
|
|
|
LOL... Thank you.. first simple solution I have ran across.
Thank you very much for your help
|
|
|
|
|
what code or function can i use to display the files in a directory in a console( but only the file names, none of the detailed stuff like is shown in DIR) and is it possible to transfer a variable in my C++ program to DOS, like if i told them to input the name of the file they want to open, but it needs to be compatable with up to 900 files in the folder(so i can't use switch() ) thanks, not sure if this can be done though
|
|
|
|
|
write your own code to list the files. use FindFirstFile/FindNextFile.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
moraalg wrote:
what code or function can i use to display the files in a directory in a console( but only the file names, none of the detailed stuff like is shown in DIR)
Have you tried to, at a command prompt, type
dir /?
?
If you had, you should probably have seen a switch "/B". If not, you are using an older OS that won't support this, and have to FindFirstFile&co yourself.
is it possible to transfer a variable in my C++ program to DOS
To DOS?! Are you really sure you are using VC1.52c and really sure you want to "transfer" it to dos???
like if i told them to input the name of the file they want to open, but it needs to be compatable with up to 900 files in the folder(so i can't use switch() )
Um, you want a user to be able to type in from 1 to 900 (!) filenames that you are then to operate on (not that I see how this has anything to do with sending stuff to DOS)?
If you really want the users to type this stuff in, one filename at a time, use cin. If you on the other hand can accept (the more reasonable) argv/argc way of handling this, just loop over argv and "do your thing".
|
|
|
|
|
Hi,
Has anybody had to to sort the contents of a list control by double clicking on the column header? if so pls tell me how to do the same.
Aravindan Premkumar
|
|
|
|
|
There are several solutions. One solution is to remove all items and insert new items in sorted order.
As for the column header, add a handler.
Kuphryn
|
|
|
|
|
Hi kuphryn,
I did that mate. i added a handler for mouse double click but the that traps only the double click on the list control items and not the header. do you know why is that?
|
|
|
|
|
Here is the code, it is desribed in the MSDN, (has been modied, original version was cut/pasted incorrectly)
ON_NOTIFY(LVN_COLUMNCLICK, OnColumnclickList)<br />
<br />
static int CALLBACK CompareCtrlEdit(LPARAM lParam1, LPARAM lParam2, LPARAM lParam)<br />
{<br />
CListCtrlEdit* pListCtrl = (CListCtrlEdit*) lParam<br />
<br />
CString strItem1 = pListCtrl->GetItemText(lParam1, pListCtrl->m_nCol );<br />
String strItem2 = pListCtrl->GetItemText(lParam2, pListCtrl->m_nCol );<br />
return strcmp(strItem2, strItem1);<br />
}<br />
<br />
<br />
void CListCtrlEdit::OnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult) <br />
{<br />
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;<br />
<br />
m_nCol = pNMListView->iSubItem<br />
<br />
ListView_SortItemsEx(GetSafeHwnd(), CompareCtrlEdit, (LPARAM) this);}
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Theres a sortlistctrl in CP in the listboxes section...its really cool and adaptable...
|
|
|
|
|
I had a look at that, the authors technique is to keep a copy of all the data in the listcontrol as the lParam the MSDN example, which I have corrected, sorry, uses only the data in the control, the trick being to use ListView_SortItemsEx() macro.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
I tried your solution but I got "'ListView_SortItemsEx' : undeclared identifier" compiler error. I have included "commctrl.h" already. What am I missing? Thanks a lot.
|
|
|
|
|
"Simple" really;) I assumed it was part of Visual C++, it is in commctrl.h BUT on the Nov 2001 SDK.
So either install the SDK, I assume a later one will be just as good, or email me and I will send you a copy of commctrl.h but I can't guarantee that would work as there may be some dependecies I don't know about
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Hey, I'm making my first MFC program and one of the things I'm trying to do is to take the information from 4 other edit boxes and output them into another edit box as 1 string. How can I do this?
I tried something like below but it did not work:
<br />
UpdateData();<br />
m_FullName.Format("%s", Your name is "<< m_FirstName <<" "<< m_LastName <<".);<br />
UpdateData(FALSE);<br />
|
|
|
|
|
Not sure why you have all those << in there, that's STL stream syntax. To understand Format() you'll need to understand printf() format strings. What you'd do is:
m_FullName.Format ( "Your name is %s %s.", (LPCTSTR) m_sFirstName, (LPCTSTR) m_sLastName );
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
thank you so much Mike.
|
|
|
|
|
Here I go again... Should be simple, but it's looking like a lot more work than I thought.
I want to display an image that's either a red, green or gray light (led) in a dialog box. I'm just starting the search for how this can be accomplished, and it's not looking promising for a simple solution. I'm thinking I'm going to have to create my own class derived from CButton, and "draw" the button to include the "light". Seems like a lot of work, so I thought I'd see if there was some (hopefully) simpler approach that someone can point me to.
Thanks.
|
|
|
|
|
Create a CStatic object on your dialog, and use the function CStatic::SetBitmap to switch between the different images that you want to use.
Good luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hello,
I want to create an array for a listbox to list files that can be opened by my program, say everyfile in the same directory with the extension '.xyz'. How do I go about doing this?
|
|
|
|
|
FindFirstFile, FindNextFile
When history comes, it always takes you by surprise.
|
|
|
|
|
//following code is in a thread to read pipe input
while(bLoop)
{
b=ReadFile(hError,szBuf,500,&dwRead,0);
if((b==0)||(dwRead==0))
{
//line a: how to come to this line?
break;
}
//do something
}
//-----------------------------------------
line a is important because it is only break point of the thread.
from all of "exemples" and books, i found none of them really comes to the point of line a. they just exit from main process and leave it to OS.
sending a null string at other side of the pipe will not cause code going to line a.
i guess only error can do that.
any idea?
thx.
includeh10
|
|
|
|
|
The process on the other end of the pipe has to close its end for ReadFile() to return false. Reading from an empty (but still open) pipe is not an error, it just waits for data to appear in the pipe.
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
I'd like to increase the spacing between the items in report view of my owner-drawn CListCtrl. Does anyone know how to do this?
Thanks in advance.
|
|
|
|