|
From: Daniel G. <dgo...@eh...> - 2006-12-31 04:51:32
|
Brian Dessent wrote:
> Daniel Goldman wrote:
>
>
>>I included the test program below with single treeview checkbox. Anybody
>>know why the checkbox is not getting checked in the cross-compiled
>>version? Am I doing something wrong? One of TreeView_SetCheckState,
>>TreeView_SetItemState, or TVM_SETITEM not working correctly?
>
>
> I don't know enough about treeview controls to audit your code, sorry.
> But I suggest that you not focus on the red herring of native/cross, and
> instead search for undefined behavior (e.g. accidently using a value
> uninitialized.) This sort of thing -- behavior that changes with
> compiler versions or other environmental factors that should logically
> have no effect -- is the classic trademark of unknowingly or accidently
> invoking undefined behavior, which is quite easy to do in modern C.
>
> Compile with -Wall and rectify all warnings, check the return value of
> all function calls, and so on. (The latter is good programming practice
> anyway, so I would do it regardless of any debugging efforts.)
>
> Brian
>
I double-checked with -Wall (which I usually do but had not here). There
were
no warnings. Thanks for the good advice.
You're right, it's probably something wrong I'm doing, but there is a
slight
chance it's something wrong with cross-compiler.
Here's the relevant code (complete code in original post), for anyone
familiar with treeview controls:
Tree_g = CreateWindow (WC_TREEVIEW, NULL,
TVS_HASBUTTONS | WS_VISIBLE | WS_BORDER | WS_CHILD,
10, 10, 100, 100, MainWin_g, (HMENU) 3, HInstance_g, NULL) ;
dwStyle = (DWORD) GetWindowLongPtr (Tree_g, GWL_STYLE);
dwStyle |= TVS_CHECKBOXES;
SetWindowLongPtr (Tree_g, GWL_STYLE, (LONG_PTR) dwStyle);
Here's the code for adding item with checkbox:
TreeView_DeleteAllItems (Tree_g);
memset (&tvis, 0, sizeof (tvis));
memset (&tvi, 0, sizeof (tvi));
tvi.mask |= TVIF_TEXT;
tvi.pszText = "1";
tvis.hParent = TVI_ROOT;
tvis.hInsertAfter = TVI_LAST;
tvis.item = tvi;
hItem = TreeView_InsertItem (Tree_g, &tvis);
TreeView_SetCheckState (Tree_g, hItem, TRUE);
Thanks,
Daniel
|