I have created a win32 instant messenger program and am porting it over to
PocketPC. Thankfully, I already had the program as unicode as I believe
this was a requirement for PocketPC. Anyway, the port has gone quite well,
I've had to lose a lot of functionality as it isnt required on the handheld
device. So far, I have my program running and working fine but there are a
few things I would like to get working a bit neater (as far as the GUI is
concerned).

Firstly, I would like my window to appear almost fullscreen, that is filling
the screen of the handheld device but with the task bar at the bottom and
the usual title bar at the top. So far, my window is almost doing this, I
can see the title bar fine but my window extends over thet ask bar at the
bottom. What should I do to create a window so that this doesnt happen?

I am trying to add a menu to my app, and am using the following code:
mHwndCB = CommandBar_Create(GetModuleHandle(NULL), mHwnd, 0);
CommandBar_InsertMenubar(mHwndCB, GetModuleHandle(NULL), IDR_MENU1, 0);
CommandBar_AddAdornments(mHwndCB, 0, 0);
CommandBar_Show(mHwndCB, TRUE);
None of the commands return failure, but the command bar doesnt appear to
show. I am confused by what msdn says about InsertMenuBar and the final
param, I have no buttons inserted. Can anybody tell me how I can get this
menu showing correctly?

Finally, I am using an edit control ("edit" class) and I want to change the
colour and size of the text, how can I do this?

Many Thanks.
Allan

Re: New to Pocket PC devel, porting win32 app by TJ

TJ
Wed Aug 17 15:24:57 CDT 2005

CommandBar is from previous versions of WinCE. WinCE 3.0+ uses
SHCreateMenuBar.

Here's an example of how it works:
SHMENUBARINFO mbi;
memset(&mbi,0,sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.nToolBarId = MYMENU;
mbi.hInstRes = hInst;
mbi.dwFlags=SHCMBF_COLORBK;
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
mbi.clrBk=RGB(178,70,178);
mbi.hwndMB=0;
SHCreateMenuBar(&mbi);
hmenu=mbi.hwndMB;

To set a font:
myfont = CreateFont( 12, /* Height */
0, /* Width */
0, /* Angel */
0, /* Orientation */
FW_NORMAL, /* Weight */
FALSE, /* Italics */
FALSE, /* Underline */
FALSE, /* Strikethrough */
OEM_CHARSET, /* Charset */
OUT_DEFAULT_PRECIS, /* Output
Precision */
CLIP_DEFAULT_PRECIS, /* Clip Precision */
DEFAULT_QUALITY, /* Quality */
DEFAULT_PITCH, /* Pitch */
"Terminal"); /* Font name */
SendMessage(hedit,WM_SETFONT,(WPARAM)myfont,(LPARAM)TRUE);

To set font color:

heditdc=GetDC(hedit);
SetTextColor(heditdc,RGB(255,0,0));




Allan Bruce wrote:
> I have created a win32 instant messenger program and am porting it over to
> PocketPC. Thankfully, I already had the program as unicode as I believe
> this was a requirement for PocketPC. Anyway, the port has gone quite well,
> I've had to lose a lot of functionality as it isnt required on the handheld
> device. So far, I have my program running and working fine but there are a
> few things I would like to get working a bit neater (as far as the GUI is
> concerned).
>
> Firstly, I would like my window to appear almost fullscreen, that is filling
> the screen of the handheld device but with the task bar at the bottom and
> the usual title bar at the top. So far, my window is almost doing this, I
> can see the title bar fine but my window extends over thet ask bar at the
> bottom. What should I do to create a window so that this doesnt happen?
>
> I am trying to add a menu to my app, and am using the following code:
> mHwndCB = CommandBar_Create(GetModuleHandle(NULL), mHwnd, 0);
> CommandBar_InsertMenubar(mHwndCB, GetModuleHandle(NULL), IDR_MENU1, 0);
> CommandBar_AddAdornments(mHwndCB, 0, 0);
> CommandBar_Show(mHwndCB, TRUE);
> None of the commands return failure, but the command bar doesnt appear to
> show. I am confused by what msdn says about InsertMenuBar and the final
> param, I have no buttons inserted. Can anybody tell me how I can get this
> menu showing correctly?
>
> Finally, I am using an edit control ("edit" class) and I want to change the
> colour and size of the text, how can I do this?
>
> Many Thanks.
> Allan
>
>

Re: New to Pocket PC devel, porting win32 app by r_z_aret

r_z_aret
Wed Aug 17 16:46:45 CDT 2005

On Wed, 17 Aug 2005 11:26:25 +0100, "Allan Bruce" <amb@abc.net> wrote:

>I have created a win32 instant messenger program and am porting it over to
>PocketPC. Thankfully, I already had the program as unicode as I believe
>this was a requirement for PocketPC. Anyway, the port has gone quite well,
>I've had to lose a lot of functionality as it isnt required on the handheld
>device. So far, I have my program running and working fine but there are a
>few things I would like to get working a bit neater (as far as the GUI is
>concerned).
>
>Firstly, I would like my window to appear almost fullscreen, that is filling
>the screen of the handheld device but with the task bar at the bottom and
>the usual title bar at the top. So far, my window is almost doing this, I
>can see the title bar fine but my window extends over thet ask bar at the
>bottom. What should I do to create a window so that this doesnt happen?
>

See my 19 June 2003 contribution to a thread called "Fullscreen" in
comp.os.ms-windows.programmer.win32. It provides source code for
related functions that work on several versions of Windows CE and
"big" Windows.


clip


>
>Finally, I am using an edit control ("edit" class) and I want to change the
>colour and size of the text, how can I do this?

I'm not sure about color/colour. But for hints about size, see my 19
January 2004 contribution to a thread called " How to change font size
in List Control" in this newsgroup.

>
>Many Thanks.
>Allan
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

Re: New to Pocket PC devel, porting win32 app by r_z_aret

r_z_aret
Wed Aug 17 16:46:44 CDT 2005

On Wed, 17 Aug 2005 15:24:57 -0500, TJ <someone@somewhere.com> wrote:

>CommandBar is from previous versions of WinCE. WinCE 3.0+ uses
>SHCreateMenuBar.

Actually, SHCreateMenuBar is for the Pocket PC and Smartphone
_platforms_, no matter what the version of the base (Windows CE)
operating system. It definitely works under versions 3.0 and 4.2 of
the base operating system (HPC 2000 and some industrial devices that
use Windows CE but don't fit any Microsoft platform).

Older Pocket PC platforms (the original and 2002) let applications use
the CommandBar_Create. Applications that use it run in "emulation"
mode, with the Task Bar at the bottom of the screen and the
application menu at the top. As of Pocket PC 2003 (or perhaps 2003
SE), the function seems to work but the menu is not visible (as the OP
noted).


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

Re: New to Pocket PC devel, porting win32 app by Allan

Allan
Wed Aug 17 16:46:42 CDT 2005


"TJ" <someone@somewhere.com> wrote in message
news:zbSdnSKemaeEAJ7eRVn-qA@midco.net...
> CommandBar is from previous versions of WinCE. WinCE 3.0+ uses
> SHCreateMenuBar.
>
> Here's an example of how it works:
> SHMENUBARINFO mbi;
> memset(&mbi,0,sizeof(SHMENUBARINFO));
> mbi.cbSize = sizeof(SHMENUBARINFO);
> mbi.hwndParent = hwnd;
> mbi.nToolBarId = MYMENU;
> mbi.hInstRes = hInst;
> mbi.dwFlags=SHCMBF_COLORBK;
> mbi.nBmpId = 0;
> mbi.cBmpImages = 0;
> mbi.clrBk=RGB(178,70,178);
> mbi.hwndMB=0;
> SHCreateMenuBar(&mbi);
> hmenu=mbi.hwndMB;
>
> To set a font:
> myfont = CreateFont( 12, /* Height */
> 0, /* Width */
> 0, /* Angel */
> 0, /* Orientation */
> FW_NORMAL, /* Weight */
> FALSE, /* Italics */
> FALSE, /* Underline */
> FALSE, /* Strikethrough */
> OEM_CHARSET, /* Charset */
> OUT_DEFAULT_PRECIS, /* Output Precision
> */
> CLIP_DEFAULT_PRECIS, /* Clip Precision
> */
> DEFAULT_QUALITY, /* Quality */
> DEFAULT_PITCH, /* Pitch */
> "Terminal"); /* Font name */
> SendMessage(hedit,WM_SETFONT,(WPARAM)myfont,(LPARAM)TRUE);
>
> To set font color:
>
> heditdc=GetDC(hedit);
> SetTextColor(heditdc,RGB(255,0,0));
>
>
>
>

I tried to do the font changes and add the manu bar but I get compiler
errors. I included AYGSHELL.H for the menubar stuff, but it has an error:
:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\aygshell.h(285) : error C2061: syntax error : identifier
'SIPSTATE'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\aygshell.h(475) : error C2061: syntax error : identifier
'IShellPropSheetExt'

And I cannot get the CreateFont to work, msdn says to include Afxwin.h but
it doesnt work - I think maybe because I am not using MFC?

Thanks.
Allan



Re: New to Pocket PC devel, porting win32 app by TJ

TJ
Wed Aug 17 17:15:01 CDT 2005

Try using CreateFontIndrect with a logical font instead.

As for the aygshell.h problems I'm not sure why the header would be
throwing errors like that. Try commenting out those lines.


Allan Bruce wrote:
> "TJ" <someone@somewhere.com> wrote in message
> news:zbSdnSKemaeEAJ7eRVn-qA@midco.net...
>
>>CommandBar is from previous versions of WinCE. WinCE 3.0+ uses
>>SHCreateMenuBar.
>>
>>Here's an example of how it works:
>> SHMENUBARINFO mbi;
>> memset(&mbi,0,sizeof(SHMENUBARINFO));
>> mbi.cbSize = sizeof(SHMENUBARINFO);
>> mbi.hwndParent = hwnd;
>> mbi.nToolBarId = MYMENU;
>> mbi.hInstRes = hInst;
>>mbi.dwFlags=SHCMBF_COLORBK;
>> mbi.nBmpId = 0;
>> mbi.cBmpImages = 0;
>>mbi.clrBk=RGB(178,70,178);
>>mbi.hwndMB=0;
>> SHCreateMenuBar(&mbi);
>>hmenu=mbi.hwndMB;
>>
>>To set a font:
>> myfont = CreateFont( 12, /* Height */
>> 0, /* Width */
>> 0, /* Angel */
>> 0, /* Orientation */
>> FW_NORMAL, /* Weight */
>> FALSE, /* Italics */
>> FALSE, /* Underline */
>> FALSE, /* Strikethrough */
>> OEM_CHARSET, /* Charset */
>> OUT_DEFAULT_PRECIS, /* Output Precision
>>*/
>> CLIP_DEFAULT_PRECIS, /* Clip Precision
>>*/
>> DEFAULT_QUALITY, /* Quality */
>> DEFAULT_PITCH, /* Pitch */
>> "Terminal"); /* Font name */
>> SendMessage(hedit,WM_SETFONT,(WPARAM)myfont,(LPARAM)TRUE);
>>
>>To set font color:
>>
>>heditdc=GetDC(hedit);
>>SetTextColor(heditdc,RGB(255,0,0));
>>
>>
>>
>>
>
>
> I tried to do the font changes and add the manu bar but I get compiler
> errors. I included AYGSHELL.H for the menubar stuff, but it has an error:
> :\program files\windows ce tools\wce420\pocket pc
> 2003\include\armv4\aygshell.h(285) : error C2061: syntax error : identifier
> 'SIPSTATE'
> c:\program files\windows ce tools\wce420\pocket pc
> 2003\include\armv4\aygshell.h(475) : error C2061: syntax error : identifier
> 'IShellPropSheetExt'
>
> And I cannot get the CreateFont to work, msdn says to include Afxwin.h but
> it doesnt work - I think maybe because I am not using MFC?
>
> Thanks.
> Allan
>
>

Re: New to Pocket PC devel, porting win32 app by Allan

Allan
Wed Aug 17 17:19:42 CDT 2005

>
> To set font color:
>
> heditdc=GetDC(hedit);
> SetTextColor(heditdc,RGB(255,0,0));
>

This doesnt seem to work, should it matter if my edit control is read only?
Thanks.
Allan




Re: New to Pocket PC devel, porting win32 app by Allan

Allan
Wed Aug 17 17:29:50 CDT 2005


"TJ" <someone@somewhere.com> wrote in message
news:Pq6dnZHlzah4K57eRVn-gQ@midco.net...
> Try using CreateFontIndrect with a logical font instead.
>
> As for the aygshell.h problems I'm not sure why the header would be
> throwing errors like that. Try commenting out those lines.
>
>

CreateFontIndirect works fine. Thanks.

I get an error 120 for SHCreateMenuBar, which is 'not implemented'. Any
ideas?

Thanks.
Allan



Re: New to Pocket PC devel, porting win32 app by TJ

TJ
Wed Aug 17 18:53:11 CDT 2005

Try:

heditdc=GetDC(hedit);
SetBkMode(heditdc,TRANSPARENT);
SetTextColor(heditdc,RGB(255,0,0));

or:

heditdc=GetDC(hedit);
SetBkColor(hedit,RGB(255,0,0));
SetBkMode(heditdc,OPAQUE);

With it being a readonly edit control I don't know which would be the
proper way of doing it. The background can't be changed with a readonly
edit control but the text color can be.

Allan Bruce wrote:
>>To set font color:
>>
>>heditdc=GetDC(hedit);
>>SetTextColor(heditdc,RGB(255,0,0));
>>
>
>
> This doesnt seem to work, should it matter if my edit control is read only?
> Thanks.
> Allan
>
>
>

Re: New to Pocket PC devel, porting win32 app by TJ

TJ
Wed Aug 17 18:54:29 CDT 2005

SetBkColor(heditdc,RGB(255,0,0));

TJ wrote:
> Try:
>
> heditdc=GetDC(hedit);
> SetBkMode(heditdc,TRANSPARENT);
> SetTextColor(heditdc,RGB(255,0,0));
>
> or:
>
> heditdc=GetDC(hedit);
> SetBkColor(hedit,RGB(255,0,0));
> SetBkMode(heditdc,OPAQUE);
>
> With it being a readonly edit control I don't know which would be the
> proper way of doing it. The background can't be changed with a readonly
> edit control but the text color can be.
>
> Allan Bruce wrote:
>
>>> To set font color:
>>>
>>> heditdc=GetDC(hedit);
>>> SetTextColor(heditdc,RGB(255,0,0));
>>>
>>
>>
>> This doesnt seem to work, should it matter if my edit control is read
>> only?
>> Thanks.
>> Allan
>>
>>
>>

Re: New to Pocket PC devel, porting win32 app by Allan

Allan
Thu Aug 18 03:09:37 CDT 2005


"TJ" <someone@somewhere.com> wrote in message
news:0b2dnZ2dnZ0LnCK3nZ2dnXVQnt6dnZ2dRVn-0J2dnZ0@midco.net...
> Try:
>
> heditdc=GetDC(hedit);
> SetBkMode(heditdc,TRANSPARENT);
> SetTextColor(heditdc,RGB(255,0,0));
>
> or:
>
> heditdc=GetDC(hedit);
> SetBkColor(hedit,RGB(255,0,0));
> SetBkMode(heditdc,OPAQUE);
>
> With it being a readonly edit control I don't know which would be the
> proper way of doing it. The background can't be changed with a readonly
> edit control but the text color can be.
>

Actually, come to think of it - this looks similar to win32 code for
changing text colour only if using DrawText() or similar APIs. I am using
EM_SETCUSEL/EM_REPLACESEL to add the text to my control. In win32 I use
EM_GET/SETCHARFORMAT to change the text colour, but it doesnt appear to be
supported in win32.

Allan



Re: New to Pocket PC devel, porting win32 app by TJ

TJ
Thu Aug 18 06:22:03 CDT 2005

Yeah it's a beast when it comes to things like this. Come to think of it
I don't know if I've ever seen non-black text in any edit control for
any program I've run on PPC... Hope you can find the answer. I've
googled the hell out of it and couldn't find anything but what I already
knew.


> Actually, come to think of it - this looks similar to win32 code for
> changing text colour only if using DrawText() or similar APIs. I am using
> EM_SETCUSEL/EM_REPLACESEL to add the text to my control. In win32 I use
> EM_GET/SETCHARFORMAT to change the text colour, but it doesnt appear to be
> supported in win32.
>
> Allan
>
>

Re: New to Pocket PC devel, porting win32 app by Allan

Allan
Thu Aug 18 06:28:18 CDT 2005


"TJ" <someone@somewhere.com> wrote in message
news:Cf2dnY-C-oLG8pneRVn-tw@midco.net...
> Yeah it's a beast when it comes to things like this. Come to think of it I
> don't know if I've ever seen non-black text in any edit control for any
> program I've run on PPC... Hope you can find the answer. I've googled the
> hell out of it and couldn't find anything but what I already knew.
>
>

Oh well, guess I'll have to live with black text then!
Thanks very much for your help
Allan