NO

Author Topic: Old Dog New tricks  (Read 34366 times)

xsilvergs

  • Guest
Old Dog New tricks
« on: March 28, 2007, 12:43:24 PM »
Hi

I'm new to C and new to my pocketpc but old and a bit slow to learn so please be gentle.

I'm trying to write my first program for my pocketpc and run into a problem, I can add button and edit boxes and make things happen but my program requires a combobox.

Having added a combobox to the DLG_MAIN I've set it as a "Dropdown list" as I want the user to only use items in the list but how do I write/fill the list?

I've search the web for info but must be looking in the wrong places as I've not found anything related.

As I've said earlier I'm new to this so please be as clear as possible.

Thanks for help in advance.
« Last Edit: March 29, 2007, 02:07:48 PM by xsilvergs »

JohnF

  • Guest
Re: Od Dog New tricks
« Reply #1 on: March 28, 2007, 02:21:54 PM »
I don't do the pocketpc but assume it will be the same.

Fill in a  COMBOBOXEXITEM and send the info with SendMessage with the CBEM_INSERTITEM message.

COMBOBOXEXITEM cbei; // the struct
SendMessage(hwndCombo, CBEM_INSERTITEM, 0, (LPARAM)&cbei);

You may need to look at the MSDN library for more explanation.

http://msdn2.microsoft.com/en-us/library/ms771608.aspx

John

xsilvergs

  • Guest
Re: Od Dog New tricks
« Reply #2 on: March 28, 2007, 04:12:12 PM »
Thanks for your reply, I've got it sorted now.

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Od Dog New tricks
« Reply #3 on: March 28, 2007, 05:21:09 PM »
Check out this topic thread:
http://www.smorgasbordet.com/forum/index.php?topic=2062.0
I have posted a link there to a nice demo project using the combobox.
Regards,
David M.
No one cares how much you know,
until they know how much you care.

xsilvergs

  • Guest
Re: Old Dog New tricks
« Reply #4 on: March 29, 2007, 01:57:33 PM »
Thank you for info.

I'm moving on very slowly but enjoying every moment, I now have another question now.

How do I use the TabControl as my project needs 3 tabs?

Thanks again

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Old Dog New tricks
« Reply #5 on: March 29, 2007, 04:23:57 PM »
xsilvergs,

Here is a link to another useful demo and article on code project that makes using the tab control easy.

http://www.codeproject.com/win32/Win32SDK_C_TabCtrl.asp

regards,
DMac
No one cares how much you know,
until they know how much you care.

JohnF

  • Guest
Re: Old Dog New tricks
« Reply #6 on: March 30, 2007, 03:18:52 PM »
David, allow me to make a suggestion, all your PellesC projects include the .tag file this makes the zip unnecessarily large.

John

Offline DMac

  • Member
  • *
  • Posts: 272
Re: Old Dog New tricks
« Reply #7 on: March 31, 2007, 08:02:38 PM »
John,

Thanks for pointing that out.

Usually I get rid of the exe and the object files but that one was not obvious to me.

In the future I'll leave the tag out of the zip.

regards,
D Mac
No one cares how much you know,
until they know how much you care.

xsilvergs

  • Guest
Re: Old Dog New tricks
« Reply #8 on: April 02, 2007, 11:16:58 AM »
Me again

Is there a list/tutorial for things like, GetDlgItemText as I don't really understand the commands?

Also I'd like to find out how to make the textbox visible and invisible in code, is this posible?

This is all for PPC.
« Last Edit: April 02, 2007, 01:55:14 PM by xsilvergs »

xsilvergs

  • Guest
Re: Old Dog New tricks
« Reply #9 on: April 04, 2007, 09:06:54 AM »
I'm still struggleing, I can't work out how to make an editbox invisible.

Can somebody please help?

JohnF

  • Guest
Re: Old Dog New tricks
« Reply #10 on: April 04, 2007, 10:04:16 AM »
The ShowWindow() API will do it. Look it up on MSDN if you do not know the syntax.

John

xsilvergs

  • Guest
Re: Old Dog New tricks
« Reply #11 on: April 04, 2007, 11:21:32 AM »
Hi John, thanks for reply.

I've looked at this http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/ShowWindow.asp and am none this wiser although I can SW_HIDE.

The example I've been trying to use is from http://www.trajectorylabs.com/win32_dialog_based_application.html . They add a macro like this #define SetDlgItemFocus(hwnd,idCtl)  FORWARD_WM_NEXTDLGCTL((hwnd), GetDlgItem((hwnd),(idCtl)), TRUE, PostMessage) and then I do this SetDlgItemFocus(hwndDlg, IDC_OXY); and the focus is passed.

So for the showwindow I've added this #define SetDlgItemHide(hwnd,idCtl) FORWARD_WM_SHOWWINDOW((hwnd),GetDlgItem((hwnd),(idCtl)), TRUE, PostMessage) and tried adding this SetDlgItemHide(hwndDlg, IDCDEPTH); to implement it, but it doesn't work.

What am I doing wrong? Sorry to appear so stupid but this is my first attempt a writting in C.

Tony

JohnF

  • Guest
Re: Old Dog New tricks
« Reply #12 on: April 04, 2007, 12:23:54 PM »
No need for all those macros - they seem to be confusing you.

On the Microsoft site you would have seen this

BOOL ShowWindow(     

    HWND hWnd,
    int nCmdShow
);

That is the syntax for ShowWindow, now the parameters are hWnd and nCmdShow. Looking down where the parameters are you can see SW_HIDE. Sounds appropriate. So,

ShowWindow(hEditControl, SW_HIDE);

Will do it for you. When you want to show the edit control again use SW_SHOW instead of SW_HIDE.

All controls are in fact windows, btw.

If you don't have the edit control handle use

HWND GetDlgItem(
    HWND hDlg,
    int nIDDlgItem
);

Where hDlg is the handle to the main window or the diloag box.

nIDDlgItem is the control identifier used when you created the control.

For example - if you created the edit window with CreateWindow the 10th parameter was the indentifier, the one before hInstance.

    hwnd = CreateWindowEx( "", "", "", "",
        0, 0, 0, 0, hwndParent, (HMENU)IDENTIFIER, hInstance, NULL);

Or if you used a dialog then there would have been something like this

CONTROL "", ID_FILTER, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 8, 20, 100, 12

Where ID_FILTER was the indentifier.

John

xsilvergs

  • Guest
Re: Old Dog New tricks
« Reply #13 on: April 04, 2007, 12:44:46 PM »
John

Are you saying I only need to add one line to my code like this

ShowWindow(IDCDEPTH, SW_HIDE); where IDCDEPTH is my Editbox

When I do I get this error message

C:\Program Files\PellesC\Projects\Nitrox\main.c(248): error #2140: Type error in argument 1 to 'ShowWindow'; found 'int' expected 'struct HWND__ *'.

Tony



Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Old Dog New tricks
« Reply #14 on: April 04, 2007, 01:18:46 PM »
Retrieve the handle of the control window with GetDlgItem:
Code: [Select]
    ShowWindow(GetDlgItem(hDlg, IDCDEPTH), SW_HIDE);
Where  hDlg is the handle of your dialog.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide