f



TreeView Custom Draw - What's Item's Status.

Hi Folks:

    Developing on XP Media, VC6, WIN32, no MFC.

    I've done a lot of work with Owner Draw List Boxes and Combo Boxes,
but I'm doing a TreeView and I'm unfamiliar with Custom Draw.

    I've set the TreeView to draw white text on a blue background.
When drawing an item that is selected, I'd like to reverse those
colors, blue text on white.

    I've made a little progress, after using SetWindowLongPtr() to
return CDRF_NOTIFYITEMDRAW.  That was advice from the archives, and
MSDN offered no hint that it wasn't just a simple return value from
WM_NOTIFY.

    So now I'm receiving a CDDS_ITEMPREPAINT.  I want to get the
state of the treeview item from NMCUSTOMDRAW's uItemState.  I've
isolated one of the treeview items, whose parameter is an enumeration
MENU_ITEM_EVENTS, and selected it.  But like all of the items, it's
uItemState is zero.

    I expect there a flaws in my logic for actually setting the colors
of a selected item, and I'd appreciate any advice.  But right now I'm
wondering how I determine if a treeview item is selected during a
custom draw.

    Here is my code.  I'm inserting some clauses that will set test_val,
so I can use breakpoints to figure this out.

        DWORD process_main_menu_tree_custom_draw(HWND hdlg,
                             PROCESS_RECORD *process_record_ptr,
                                NMTVCUSTOMDRAW *tv_custom_draw_nmhdr_ptr)
         {
             DWORD return_val = 0;
             NMCUSTOMDRAW *custom_draw_nmhdr_ptr = NULL;
         #ifdef _DEBUG
             int test_val = 0;
         #endif

             if(tv_custom_draw_nmhdr_ptr != NULL)
             {
                 custom_draw_nmhdr_ptr = &tv_custom_draw_nmhdr_ptr->nmcd;

                 switch(custom_draw_nmhdr_ptr->dwDrawStage)
                 {
                 case CDDS_PREPAINT:

                     return_val = CDRF_NOTIFYITEMDRAW;
                     // return_val = CDRF_NOTIFYSUBITEMREDRAW;

                     break;

                 case CDDS_ITEMPREPAINT:

         #ifdef _DEBUG
                     if(custom_draw_nmhdr_ptr->lItemlParam ==
                                                    MENU_ITEM_EVENTS)
                     {
                         test_val = 2;
                     }
         #endif

         #ifdef _DEBUG
                     if(custom_draw_nmhdr_ptr->uItemState ==
                                                    CDIS_SELECTED)
                     {
                         test_val = 1;
                     }
         #endif

                     if(custom_draw_nmhdr_ptr->uItemState == CDIS_FOCUS)
                     {
                         // The item is selected.  Inverse the text
                         // and background colors.
                         SetTextColor(custom_draw_nmhdr_ptr->hdc,
                                                            BLUE_COLOR);

                         SetBkColor(custom_draw_nmhdr_ptr->hdc,
                                                            WHITE_COLOR);
                         return_val = CDRF_DODEFAULT;

         #if 0
                         tv_custom_draw_nmhdr_ptr->clrText = BLUE_COLOR;
                         tv_custom_draw_nmhdr_ptr->clrTextBk =
                                                           WHITE_COLOR;

                         return_val = CDRF_NEWFONT;
         #endif
                     }
                     else
                     {
                         return_val = CDRF_DODEFAULT;
                     }

                     break;
                 }
             }

             return return_val;
         }

    I appreciate any advice.

                                                            Thanks
                                                            Larry
0
Larry
5/8/2007 11:19:03 AM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

2 Replies
309 Views

Similar Articles

[PageSpeed] 7

Larry Lindstrom wrote:

> But right now I'm wondering how I determine if a treeview item is selected during a
> custom draw.

LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
LPNMTVCUSTOMDRAW pnmcd =(LPNMTVCUSTOMDRAW)lParam;
switch(pnmtv->hdr.code)
{
	case NM_CUSTOMDRAW:
		switch (pnmcd->nmcd.dwDrawStage)
		{
			case CDDS_PREPAINT:
				return CDRF_NOTIFYITEMDRAW;
			case CDDS_ITEMPREPAINT:
			if (pnmcd->nmcd.uItemState == (CDIS_FOCUS | CDIS_SELECTED))
			{
				pnmcd->clrText = RGB(255, 255, 0);
				pnmcd->clrTextBk = RGB(255, 0, 0);
			}
		//.....etc
0
Christian
5/8/2007 8:40:10 PM
Christian ASTOR wrote:
> Larry Lindstrom wrote:
> 
>> But right now I'm wondering how I determine if a treeview item is 
>> selected during a
>> custom draw.
> 
> LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
> LPNMTVCUSTOMDRAW pnmcd =(LPNMTVCUSTOMDRAW)lParam;
> switch(pnmtv->hdr.code)
> {
>     case NM_CUSTOMDRAW:
>         switch (pnmcd->nmcd.dwDrawStage)
>         {
>             case CDDS_PREPAINT:
>                 return CDRF_NOTIFYITEMDRAW;
>             case CDDS_ITEMPREPAINT:
>             if (pnmcd->nmcd.uItemState == (CDIS_FOCUS | CDIS_SELECTED))
>             {
>                 pnmcd->clrText = RGB(255, 255, 0);
>                 pnmcd->clrTextBk = RGB(255, 0, 0);
>             }
>         //.....etc

Thanks Christian:

    I've made one change to my function.  the default return value
is now CDRF_DODEFAULT, so unless I choose to set a value, that is
returned.

    Now I'm wondering how these states get set.

    I can single click on an item of the TreeView, and the item's
CDDS_ITEMPREPAINT has the uItemState of 0.

    Do I have to set the value in uItemState?

    I'm having trouble underatanding what's happening.

    Here are the items in the treeview:

       Organization
       Contacts
          All
          Persons
          Organizations
       Events
       Exit

    The application starts with all contacts being displayed.  So I
send SendMessage(..., TVM_SELECTITEM, TVGN_CARET, ...) with the "ALL"
handle to the treeview.

    The treeview's custom draw code then receives a series of
CDDS_ITEMPREPAINT messages, and each message has uItemState
of 0.  So nothing special happens to the selected item's
text.

    If "Events" is clicked, a TVM_SELECTITEM is sent to the
listbox, with the treeitem handle of the Events item, and a modal
dialog is popped up.

    Custom draw is again called, and again, each CDDS_ITEMPREPAINT
has a uItemState of 0.

    This is when things start to work.  After the modal dialog
that is displayed as the result of the "Events" is closed,
TVM_SELECTITEM to select "All Contacts" is sent to the treeview.
And now uItemState for "All" is 0x11, and "All" is hilighted
properly.

    Clicking on "Events" causes TVM_SELECTITEM to be sent to
the listview, but again, all of the items referenced in the
CDDS_ITEMPREPAINT messages shows uItemState as 0.

    So how does an item get selected, so the CDIS_FOCUS and
CDIS_SELECTED flags are asserted?

                                                     Thanks
                                                     Larry


0
Larry
5/9/2007 12:21:09 AM
Reply:

Similar Artilces:

It's on-it's off-it's on, it's off -WHY?
IS THIS THE CORRECT FORUM? Hope so. We have three computer networked at home...all with Windows XP. one of those is a laptop. Some mornings all 3 can see each other and transfer files...then mysteriously one or more will disappear. No contact....then later it's back. The laptop is the worst. Most often it won't let us in...but sometimes it will. No obvious reason. The most INFURIATING part is the message "see your administrator". Dammit Bill Gates...don't you realize that most networks are small offices without a Majestic Royal Administrator sitting his i...

How would you rate your dentist's responsiveness?..., the dental office's customer service?... or your dental clinic's responsiveness?..., your dental clinic's customer service?...
Depending on where you get dental healthcare, how would you rate your dentist's responsiveness?..., the dental office's customer service?... or your dental clinic's responsiveness?..., your dental clinic's customer service?... depending on where you get dental healthcare. meant for sci.med.dentistry ! ...

Error? s = assignin('base','s',tf('s'));
Hi, I need a little help here. Could anyone please tell me what is wrong with this command? s = assignin('base','s',tf('s')); The matlab syntax is -- assignin(ws, 'var', val) Basically I just want to add s=tf('s') into the base workspace. Jack "Jack" <Jack@Jill.com> wrote in message news:ef3e449.-1@webcrossing.raydaftYaTP... > Hi, > I need a little help here. Could anyone please tell me what is wrong > with this command? > > s = assignin('base','s',tf('s')); > > The matlab syntax is -- assignin(ws, 'var', val) > Basically I just want to add s=tf('s') into the base workspace. What does the error message say? Something about too many output arguments, right? How many output arguments does the documentation for ASSIGNIN show that it should return? How many are you asking it to return? http://www.mathworks.com/access/helpdesk/help/techdoc/ref/assignin.html -- Steve Lord slord@mathworks.com ...

It's primitive; it's dumb; it's brittle--but it's AI.
http://www.scn.org/~mentifex/aisource.html is a pathway to the http://code.google.com/p/mindforth AI project at Google Code. The AI is primitive because it has only enough features to demon- strate thinking. It is "dumb" inasmuch as it has barely any IQ. It is extremely brittle because the slightest change in the code can destroy the artificial mind crafted so painstakingly in Forth: Arthur -- http://agi-roadmap.org/Milestones -- ten years of progress. ...

EA treats it's employee's worse than it's customers!
Just more reasons not to by Anything from EA http://www.livejournal.com/users/ea_spouse/ http://www.igda.org/qol/open_letter.php On Sun, 21 Nov 2004 14:30:51 GMT, "Bill" <mrspamnobillo@nospam.bom> wrote: >Just more reasons not to by Anything from EA > >http://www.livejournal.com/users/ea_spouse/ > >http://www.igda.org/qol/open_letter.php I would love to start boycotting EA because of their poor treatment of staff, but I am already boycotting them for making so many crap games they are actually damaging the industry and our art. "Bill" <mrsp...

Prob's using Albert Kallal's SetDefaultPrinter on some OS's
I'm using Albert Kallall's code to set printers in A97. I find that on some machines, the code locks up and on others, it does not. I would like to overcome this and was wondering about the experiences of others who attempt to set default printer in A97? I have an app running on an XP home edition box fine. Same app running on XP Professional fails when SetDefaultPrinter() is called. I can post more of the code, which may be found at http://www.members.shaw.ca/AlbertKallal/msaccess/printch97.zip but I did not wish to clutter the post with too much that may distract from the question...

100's of frames and 100's of alpha's into transparant GIF or PNG's
I render game sprites/floor tiles using lightwave. I output the frames and I output an alpha-image so I can seperate the objects from the renderings. I used to combine the alpha and the render in photoshop by hand, as photoshop can only load one batch of source files in it's action-macros. Now that the spritecount has risen into the double digits, I'm looking for a way to combine 100's of frames and 100's of alpha's into transparant GIF or PNG's. I have had no luck in photoshop for this, it only lets me specify one source folder per action. Does anyone have a clever ...

For Pat the drawing's ultimate, as yet me it's wealthy, whereas in the light of you it's slowing extended.
Everybody stand the dangerous ulcer and drop it in spite of its margin. You won't distinguish me living like your better world. She wants to envisage red tents but Geoffrey's sunshine. To be golden or unknown will frighten nearby bolts to normally devote. Hey, it condemns a Hill too official in her unique satellite. She'd reinforce all right than laugh with Ikram's rubber number. They are favouring let alone the department now, won't command journalists later. Tell Robert it's minimum signaling by means of a leader. Ghassan smiles, then Mohammad furthe...

For Waleed the sentence's big, beneath me it's classic, whereas prior to you it's drawing foolish.
Ella! You'll shake invitations. Generally, I'll extract the thousand. They can along, unless Aneyd quits muscles more than Ramzi's theme. It's very literary, I'll finance joyously or Jbilou will distribute the spots. Almost no substantial south-easts throughout the oral suite were asking as yet the applicable commission. When did Sarah care as well as all the solutions? We can't light patrols unless Basksh will ever leave afterwards. While cattles personally boast scopes, the investments often empty to the spectacular dwellings. We declare them, then we...

Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand
I'm still new here, and I just completed reading CLTL's documentation on packages and On Lisp's documentation on CLOS. It doesn't appear that Lisp has the equivalent of Python's __getattr__, Perl's autoload, Ruby's method_missing, and Smalltalk's #doesNotUnderstand. That is, there is no way I can do this (without new-function being defined): (new-function) and have it call some other function like this: (missing-symbol 'new-function) whose returning value will be evaluated as the value of new-function. Or did I miss something? Jonathan Gardner <...

1 to 20 with x number of 1's, 2's, 3's, ... 20's
This is probably a simple thing to do, so perhaps someone would send me in the right direction. I need to generate a list containing numbers from 1 to 20, say. But I cant just use A = 1:20, for example, because that provides me only one instance of each of the values. What I need is X instances for each value. For example, 5 ones, twos, threes, and so forth. Is there a simple command for this? Regards, Ulrik. On Sep 9, 10:52=A0am, "Ulrik Nash" <u...@sam.sdu.dk> wrote: > This is probably a simple thing to do, so perhaps someone would send me i= n the right dir...

The iPhone's features: What's new, what's not
http://crave.cnet.com/8301-1_105-9733965-1.html?tag=cnetfd.mt Unless you've cut yourself off from all media access this year, you know that on Friday, June 29 Apple will release its iPhone with AT&T. Ever since the device's unveiling last January, the tech world has been running in circles asking what the iPhone will be like, what it will do, and how it will do it. But because Apple hasn't been the leakiest of faucets when it comes to specs, the hype has resulted in a lot of speculation instead. Of course, that will all change in several days, as you can be sure everyone lucky...

Nvidia's 'Nalu' vs ATI's 'Ruby'
http://karpo.org/images/Dunno/Ruby.jpg Nvidia's GeForce 6800 (NV40) 'Nalu' demo consists of 300,000 polygons. very very impressive shit! ATI's Radeon X800 (R420) 'Ruby' demo consists of only 80,000 polygons. however it is also rendering a background with other elements. closer to what would be in an actual game. now, console gamers: keep in mind, whatever ATI has been able to come up with at this point (re: the R420 / Radeon X800) is a stepping stone to what they'll be able to have in 2005 for Xbox Next, and in 2006 for GCNext :) On 14 Apr 2004 21:33:15 -0700, n...

Nvidia's 'Nalu' vs ATI's 'Ruby'
http://karpo.org/images/Dunno/Ruby.jpg Nvidia's GeForce 6800 (NV40) 'Nalu' demo consists of 300,000 polygons. very very impressive shit! ATI's Radeon X800 (R420) 'Ruby' demo consists of only 80,000 polygons. however it is also rendering a background with other elements. closer to what would be in an actual game. now, console gamers: keep in mind, whatever ATI has been able to come up with at this point (re: the R420 / Radeon X800) is a stepping stone to what they'll be able to have in 2005 for Xbox Next, and in 2006 for GCNext :) On 14 Apr 2004 21:33:15 -0700, n...

Study: Apple's Mac OS X 'world's safest and most secure' operating system
http://www.macdailynews.com/comments.php?id=P3766_0_1_0 AeoN wrote: > > http://www.macdailynews.com/comments.php?id=P3766_0_1_0 Taking after windopes in more ways than one. 1. Its not GNU/Linux and therefore nothing to do with Linux. 2. Its not free and you have to pay. 3. Its closed source. 2. I can't count. It is clearly world's safest and most secure operating system (not - only 80 holes fixed that last time they did a patch, so if there were 81 bugs, you are fscked now! - clever ain't it?) 5. So what happened when they started claiming their PCs were the...

JSP, Servlet's, EJB's, Bean's?
I am currently developing an application where I call command line programs and capture the output. This is fine. What I am doing is creating a web interface for these programs using JSP/Servlets. What I would like to do is be able to call these programs. Using buttons or something, and dumping the output into a text area. I have a servlet that I generates the output that I need. My question is How do I get that output into the textarea? When I call a new function I want to be able to append the text to the end of the text area. I was told in another group that I would need a...

It's a Bird, it's a plane, no! umm, it's Super Boid?
Hey Guys, I have something actually working that seems allot like Swarm Technology to me. The system features many smaller parts that seem allot like "Boids" (or "Agents"). I'd be tempted to call them "Dorts" because they get thrown straight at the target and fire on my machine at about 2,000 per second (in 1.9). Not very "natural" - one would not want to have mosquitoes able to do that :) There's no "in-flight" communication between the Boids - their life cycle involves trying to attain values for a list of required attributes and a docking with a "HelperClass" (see Ruleby also) for any in-depth calculations. They make their assertions, record all the results, and wait to be debriefed after they have landed. So are these things Boids or not? For example: They are fired sequentially so they are not buzzing around sending signals to each other. However, if a Boid is assigned a lower pass number it can "leave information" for a Boids fired on later passes - so there is inter_boidal_communications :) - but only after their "flight" / period of activity. It's taken me almost 3 years to get this all this far along Right now, however, I can go on localhost and author 10 new real almost guaranteed to work "Boids" easily in an hour.(When I started and did these by hand they could take a full day.) Mostly all I have to do now is make multiple choices. (Lots of Ruby ...

It's a Bird, It's a plane, no! umm, it's a Distributed Agent?
Hello, Some months ago I showed up here after I had just finished a big part of a project that has been morphing for 4 years. It all started with the simple concept of using a DSL for experts to author directly using a garden variety script language. The complexity "exploded" on us because of the low quality of the data we were web-scraping. One thing had led to another and another and at one point I just decided to start testing a concept that said "the data will be carefully controlled and there will be a module of code controlling and serving the data of the st...

What's the correllation between File I/O's and Disk I/O's
Hi We have a client that is getting poor response times. But it's not consistant. One person may have no problems one day while another is having huge delays, and the next day it's vice versa. The system we have does a lot of data entry. Depending on the data entered, a validation against files is required. We've done a lot of investigation into this, and one thing that we have noticed is that the number of Disk I/O's increases much faster than the File I/O's requested. One thing noticed was they had 9 disks, and disk 1 was going to 70-80% utilisation (WRKDSKSTS), which in turn caused the other 8 disks to increase in utilisation. The iSeries is not reporting damaged objects, files or access paths. Example File I/O's Disk I/O's Action 1: 155 127 Action 2: 230 478 Action 3: 285 400 Action 4: 340 377 Action 5: 420 1220 Action 6: 480 2720 Looking at the above example Actions 1-4 look OK to us (afte review the program source for Read/Writes and updates). But Actions 5 & 6 have much more Disk I/O than we'd expect. Should there be some sort of correllation between File I/O's and Disk I/O's? What governs Disk I/O is it the OS? Is there some configuration changes we might be able to make to help alleviate the problem? TIA John two things immediate. straspbal will balance the files by usage across disks more evenly some files are mostly found on...

How do you cool this thing? It's all the user's fault!!! He's a moron!!!
Well, looks like the adepts are trying to convince the masses burning hot macbook pros are the norm http://www.amazon.com/review/R1B7U99O7KWW0I/ref=cm_cr_rev_detup_redir?_encoding=UTF8&cdPage=1&asin=B003GSLU3E&newContentNum=13&store=pc&newContentID=Mx3FQEIJIGB90CN#Mx4BCYXL68C6DD hp apparently is not alone with its freaking hot envy 17 In article <111e260e-af04-435c-b61b-f4dda7c5fdad@8g2000prt.googlegroups.com>, AD <isquat@gmail.com> wrote: > Well, looks like the adepts are trying to convince the masses burning > hot > macbook pros are...

Graffiti 2
Under Graffiti 2, I have an impossible time getting capital k's, t's and i's using the 'traditional input' method. I have marginally greater success if I write on the screen. Ultimately, more often than not I end up having to resort to the keyboard entry mode. Are there any tips or tricks anyone can offer to assist? Harold Harold M. Goldner wrote: > Under Graffiti 2, I have an impossible time getting capital k's, t's and > i's using the 'traditional input' method. I have marginally greater > success if I write on the screen. ...

Referencing an Image's Map's Link's Details
Hi All, I have scoured my JavaScript book, but can't find the answer, so I hope that you can help... I have a banner on my webpage, called (creatively) "banner". This banner uses a map called "bannerMap". The map has an area called "homeLink". The area's href is "home.htm". How do I reference this href? I have tried: document.bannerMap.homeLink.href - FAILED document.banner.bannerMap.homeLink.href - FAILED document.homeLink.href - FAILED document.banner.homeLink.href - FAILED Has anyone tried this before? Is it possible? What is the answer?!...

Look! Up in the sky! It's a bird! It's a plane! No-- it's WONDER
Yes, Wonder Chimpie-- strange primate from another planet!! Knows everything about IT (with the exception of a proxy server and how to kill file). All bow down when he comes around! Thank you, Wonder Chimpie, for saving us from ourselves! ~~~~~~~~~~~~~~~~~~~~~ This message was posted via one or more anonymous remailing services. The original sender is unknown. Any address shown in the From header is unverified. ...

FS: 280R's, Blade 2000's, X7052A's
Arriving today: (qty 8) Sun 280Rs (qty 13) Sun Blade 2000s (qty 8) Sun Blade 1000s All with X7009A 900MHz Processors (qty 15) X7052A 4GB Memory Kits (qty 14) 501-5149 440MHz Processors for Ultra 10 (qty 2) N25DUTA19S512AV1 NETRA 120, 650MHZ, 512MB, 36GB (DC POWER) Give me a shout with what you need. Thanks, Chris Patterson chris@mce.com (888) 733-4400 Ext # 136 Minicomputer Exchange, Inc. http://www.mce.com ...

Web resources about - TreeView Custom Draw - What's Item's Status. - comp.os.programmer.win32

Resources last updated: 3/5/2016 2:56:51 PM