|
yep, as far as i know. it's not that hard to do though... there's a bunch of articles on how to do stuff like this here in codeproject. you could also do a search for CListCtrl::DrawItem().
cheers,
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Handle LVN_ITEMCHANGING. Examine the iItem and uNewState members of the struct you are passed, and if an item is becoming selected, and you don't want it to be, return TRUE from the handler to prevent the change.
--Mike--
"alyson hannigan is so cute it's crazy" -- Googlism
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
please elaborate if possible
a code snipet would be helpful
|
|
|
|
|
I have never gotten an error in release mode that I did not get in debug mode. In CView::OnFilePrint() somewhere between OnBeginPrinting and OnPrepareDC (the two functions I can override and put some message boxes in so I can see where I am while in release mode) I am getting this:
Unhandled exception at 0x0050f277 in Paradigm.exe: 0xC0000005: Access violation reading location 0x00000002.
I have exhausted my knowledge trying to figure out why this is happening.
I can set a breakpoint for this address and it hits it three other times during execution before it bombs in OnFilePrint(). VS says there is no source code associated with this address. The dissassembly is as follows:
0050F277 66 81 7B 02 FF FF cmp word ptr [ebx+2],0FFFFh
Where do I go from here? I'm sure there are things to do that are outside my knowledge base. It works perfectly in debug mode.
Ed
|
|
|
|
|
There is a good article here on CP about how to fool the debug version into thinking it's a release version, so you can catch these errors in the debugger.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Greetings all,
I have a question. I'm using Norm Almond's CLabel control on a Property Page. I want to allow the user to select some colors and then have a rectangle on the dialog with the color the user chose. It was working perfectly as a CDialog.
What's happening now is I'm trying to make that dialog a PropertyPage as part of a PropertySheet. Here are the changes I made to InitInstance:
BOOL CPropertySheetDemoApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
/*CPropertySheetDemoDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}*/
CPropertySheet mySheet;
CMyPropertyPage myDemoPage;
myDemoPage.m_lblTest.SetBkColor(RGB(1.0, 1.0, 1.0));
mySheet.AddPage(&myDemoPage);
mySheet.DoModal();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
As you can see I just commented out the stuff to bring up the initial dialog and am trying to bring up the property sheet instead. The error I'm getting is a debug assertion failure in the UpdateSurface() method of the CLabel class. It seems to be complaining that the window hasn't been drawn or doesn't have an hWnd yet.
Any suggestions? I just want to be able to initialize the colors on the labels as they come up, and they may not always be the same colors.
I'd appreciate any suggestions!
Joe
|
|
|
|
|
Hi!!
I have a connection between two computers, that work's OK. Command NETSTAT show the ESTABLISHED status under this connection, but I need to receive from a third computer. On the 3rd computer, the NETSTAT command show the ESTABLISHED status too, but the CSocket::Receive from the server, can not listen from there...
what was wrong?
Thank's.... Walote
|
|
|
|
|
Hello,
I have a UI thread and I do a PostMessage from the thread to the application with the lParam set as a CString.. in my receiving function i do a
LRESULT CMainFrame::OnMarkOffLine(WPARAM wParam, LPARAM lParam)
{
CString* name = (CString*)lParam;
CString strName = *name;
..SNIP........
but i am getting a access violation here...
CString::CString(const CString& stringSrc)
{
ASSERT(stringSrc.GetData()->nRefs != 0); <-Here
if (stringSrc.GetData()->nRefs >= 0)
{
ASSERT(stringSrc.GetData() != _afxDataNil);
m_pchData = stringSrc.m_pchData;
InterlockedIncrement(&GetData()->nRefs);
}
else
{
Init();
*this = stringSrc.m_pchData;
}
}
What am I doing wrong??
|
|
|
|
|
There is nothing inherently wrong with the code you posted (although I would recommend that you replace the C-style typecast with a more appropriate C++ typecast but that's another matter altogether). Show us the code that sends (or posts) this message.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Here's the PostMessage
PostMessage(this->GetMainWnd()->GetSafeHwnd(),UWM_OFFLINE,0,(LPARAM)&m_strDns);
|
|
|
|
|
CString name = (LPCSTR)lParam;
instead of the
CString* name = (CString*)lParam
|
|
|
|
|
Actually the error went away but the string contains garbage..
|
|
|
|
|
I know exactly what your problem is!
You can't use pointers to objects with a PostMessage(), because PostMessage() does not hang the calling thread and wait until the receiving thread processes the message, unlike SendMessage(). What happens is that the CString object in your calling thread gets destroyed before the receiving thread gets a chance to access the strings contents.
The solution to this is kind of a pain. You need to create a central map / list container that holds a bunch of strings, and then pass handles (or even pointers) to those strings in your messages. Then you delete the string once you receive the message, or perhaps after some time.
Hope this helps!
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
When using PostMessage with non-primitive data types, alwaysuse a deep copy of the object - passing a reference to an object that might cease to exist before the message is handled is just asking for trouble:
CString * lp = new CString(m_strDns);
if (!PostMessage(...,...,..., (LPARAM) lp))
delete lp;
the error handler avoids a memory leak (although you might be tempted to retry posting the message if your handling would break down otherwise)
the message handler needs to delete the object again:
CString* name = (CString*)lParam;
_ASSERTE(name!=NULL)
CString strName = *name;
delete name;
This solution is IMO easier than the one suggested in the post above..
*) reason:
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
Thanks to both of you for your posts.. I had a feeling that the thread was exiting before the string could be accessed by my main app.. I went with the easier solution posted below..
Thanks again,
Rob
|
|
|
|
|
You're welcome. Just make sure that you don't post the message to multiple windows, or else the object will be deleted before the second window processes the message
swine
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
I have a simple SDI MFC application.
When I click on the view I show popup menu.
In the OnDraw function of my view I draw some things and I want to know,
if the popup menu is shown, because I want to mark the point where I clicked with
the mouse to open the popup menu!
I want to do like something:
...
if (???->???())
{
... draw a point ...
}
So, how can I check if the popup menu is shown????
Here the code I use to show the popup menu:
CMenu menu;
menu.LoadMenu(IDR_POPUPS);
menu.GetSubMenu(1)->TrackPopupMenu(TPM_LEFTALIGN | TPM_VERTICAL | TPM_NONOTIFY,
pInfo->ptAction.x, pInfo->ptAction.y, this);
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
I think the problem is to know when menu is closed (you know exaclly when it is opened). It is not problem also to detect when user closes context menu selecting it's item. The last thing you need is to know when user closes menu without selecting item.
Playing with Notepad and Spy++ I found that when I close context menu pressing Esc Spy++ prints the line:
S WM_MENUSELECT uItem: 0 fuFlags:FFFF(menu was closed) hMenu:00000000
Try to investigate this.
|
|
|
|
|
Say I have two views in my application v1 and v2 that belong to class v1 and class v2 ;
Both these views have the same parent frame type i.e same Parent Frame class F
In F's ActivateFrame Method i need to make a decision based on the view .As for eg I want to show v1 as Maximized , but v2 as minimized . How can I get run time class information from the View ??????
All i can do i ActivateFrame() is
this->GetActiveView() and check the class information and make a decision !
|
|
|
|
|
You can use the RTTI mechanism provided by MFC to determine what type you have as follows:
CView* pView = GetActiveView();
if ( pView != NULL )
{
if ( pView->IsKindOf( RUNTIME_CLASS(CMyView1) ) )
{
// Do something
}
else if ( pView->IsKindOf( RUNTIME_CLASS(CMyView2) ) )
{
// Do something different
}
}
Dave
|
|
|
|
|
What I want to Happen: If function is called, open another webbrowser if one is open already.
Problem: Function uses same instance of default webbrowser when called
Sample Code:
ShellExecute(m_hWnd, "open", str_Homepage, NULL, NULL, SW_SHOWDEFAULT);
I tried researching this one, can not jump the hurdle.
Thanks
Joe
"You can't throw yourself a parade every time you win, and you can't bury yourselves when you lose."-Levon Kirkland Philadelphia Eagles
|
|
|
|
|
<br />
ShellExecute( m_hWnd, _T("open"), _T("iexplore.exe"), str_Homepage, NULL, SW_SHOWDEFAULT );<br />
should do the trick. This will of course always open Internet Explorer however.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Perfect thanks!
"You can't throw yourself a parade every time you win, and you can't bury yourselves when you lose."-Levon Kirkland Philadelphia Eagles
|
|
|
|
|
If you don't want to read this lengthy explanation here is the question first.
Does anyone have any "gotcha" type of information on MSMQ or any type of message queue architecture or suggestions as to whether this is a viable solution? Or, of any other alternative solutions, I should consider?
Problem(s):
Multiple applications written by different developers (from different groups/orgs) without a standard library or core set of functions. This causes alot of redundant coding and a lack of standardization. i.e. file I/O routines are duplicated/redundant, the format of the data is basically the same but are sometimes treated differently by different software authors. Most applications are either analysis (algorithmic) or empirical representations of the data. No standards exist for the algorithms, and so many programs exist some of which perform analysis better than others.
Additionally, the developers use either C, C++ (Microsoft, Borland, MFC, OWL) or VB. Some of the apps are realtime but most do post analysis of the data. I must also state that there is no central organization in a position of authority to fully mandate standards or even require what applications be developed and their priorities.
Sounds silly? Yeah, welcome to the US govt agency I work for. I have been trying to coordinate a cooperative agreement on some development standards but am finding this very difficult. We have pockets of one or two developers spread throughout the country, developing in their language/development suite of their choice. The biggest problem, of course, is a lack of funding (resources) and one organization to implement a central plan not to mention defensive territorialism by managers who control these developers. On the positive side, at least we are all developing in Windows since DOS is so outdated but there was a time when very few of us developed for Windows.
Thus, for the past year or so I have been trying to come up with a plan that may not address all issues but at least make us more efficient. Initially, I looked at COM but then realized that our agency does not have enough qualified personnel to develop for COM.
Possible Solution:
My next approach that I am considering is a compromise. My group (presently 2 people) has developed a standard core library we would like to implement in some form but the language compatability problems arise. Thus, I am thinking to ignore/dump support for VB or Delphi but instead support C or C++ for Microsoft only. I have converted our core library from Borland C++ to VC++ and it currently has no GUI built for it.
If I provide this core library in VC/C++ or MFC, then previously developed apps should be able to use it without too much modifications as long as they also were written in VC/C++ or MFC. I am thinking that if we used some form of queing architecture such as MSMQ (or whatever its called now), then my group can maintain the core, and we can deliver a standard core library or interface. I'm figuring that previously developed applications could modify their file I/O routines to connect to the queue architecture and receive data messages from that instead. Another side benefit, is that a good queue architecture can encapsulate networking code for us, so that not all developers would need to learn that, and we could have some true client/server based applications.
This resolves standardization issues regarding data, File I/O, and realtime data handling routines, but still does not address standards regarding algorithms, programming languages, or develoment environments. Thus, the compromise. Additionally, the message queue architecture may even allow us to use different languages and support other platforms (I don't know if MSMQ will do this) if we make interfacing to the core library, totally message based. I should say that a standard programming language or platform is not mandatory, and in the best case scenario we would like to support multi-platforms and languages, if such a message queue architecture or other exists.
Does anyone have any "gotcha" type of information on MSMQ or any type of queue architecture or suggestions as to whether this is a viable solution? Or, of any other alternative solutions, I should consider?
Sorry, so long. Thanks in advance for any info.
|
|
|
|
|
I am using CreateFont to create the appropriate font to use in the print preview of my application. For example ->
m_PrintFont.CreateFont(80,34,0,0,0,0,0,0,0,0,0,0,FIXED_PITCH,"");
I understand that CreateFont uses the font that most closely matches what you ask for. The problem is that this works on my machine, but other machines do not output the same font. I'm assuming if I can figure out which font is being chosen on my machine, I can copy it to other machines and it will choose the same one. So how do I know exactly which font it is actually using on my machine?
Ed
|
|
|
|
|