FullScreen OpenGLES application - Touch Diamond, MDA Compact IV Themes and Apps

Hello,
I'm trying to do an OpenGLES application for my HTC Touch Diamond.
I create the window with CreateWindow :
Code:
INT width = ::GetSystemMetrics(SM_CXSCREEN) ;
INT height = ::GetSystemMetrics(SM_CYSCREEN) ;
hWnd = ::CreateWindow(
m_szAppName, m_szAppName,
WS_VISIBLE,
0, 0, width, height,
NULL, NULL, m_hInstance, NULL
) ;
SHFullScreen(hWnd, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
The problem is that (width,height) equals (240,320) even if the screen is VGA (480*640). So OpenGL windows just fills a quarter of the screen.
And when I try to set (width,height) to (480, 640), CreateWindow throws an "Error 4".
Has anybody the solution ?
Thanks

Hello !
I found the solution: I need to had the ressource HI_RES_AWARE.
We can find some tutorials on the web to explain how to had this.
Bye

Related

Dialog Background Image

Hi all,
Is it possible to display a background image on a dialog rather than the white background. I am fairly certain that it is possible to change the background colour but I wish to display a transparent image"behind" the dialogs components.....
Regards Gerard
The method is the same as on normal PC - process WM_ERASEBKGND message.
Thanks for the reply,
I have managed to display my bitmap as the dialog background. I now wish to make all components on the dialog transparent.
Currently I am painting the bitmap through, in WM_PAINT:
CRect rect;
GetClientRect(hDlg, &rect );
PAINTSTRUCT ps;
BITMAP bm;
HDC hdc = BeginPaint(hDlg, &ps);
HDC hdcMem = CreateCompatibleDC( hdc );
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, g_hBmDlgBack);
GetObject(g_hBmDlgBack, sizeof(bm), &bm);
StretchBlt(hdc, 0, 0, rect.Width(), rect.Height(), hdcMem, 0,0,47, 47, SRCCOPY );//BitBlt
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
EndPaint(hDlg, &ps);
I then attempt to process each component and make transparent:
CRect rcBitmap(0, 0, bm.bmWidth, bm.bmHeight);
//SetBkMode(hdcMem, TRANSPARENT);
for(int i=0; i<sizeof(IDs)/sizeof(IDs[0]); i++){
HWND pChild = GetDlgItem(hDlg,IDs);
CRect rcChild;
GetWindowRect(pChild, &rcChild);
POINT lpPoint;
lpPoint.x = rcChild.left;
lpPoint.y = rcChild.right;
ScreenToClient(pChild, &lpPoint);
CRect rcToCopy;
IntersectRect(&rcToCopy,&rcChild, &rcBitmap);
PAINTSTRUCT ps;
HDC temphdc = BeginPaint(pChild, &ps);
SetBkMode(temphdc, TRANSPARENT);
BitBlt(hdcMem,0,0,rcToCopy.Width(),rcToCopy.Height(), temphdc, rcToCopy.left, rcToCopy.top,SRCINVERT );//copy
DeleteDC(hdc);
EndPaint(pChild, &ps);
}
This code has no effect however. Can anyone assist in where Im going wrong? Also, one of my components is a list control-> is it even possible for this to be set transparent?
Regards Gerard
I have came across some hopeful avenues but with no success..
The TransparentImage works correctly, ie makes certain parts of my bitmap transparent based on a certain colour. However, now I must use GetPixel or something similiar to determine what to replace the transparency with..
Is there anyone out there who can assist me in implementing a transparent control?? I know it possible just not having any luck.
Pls help.
Regards Gerard

Simulate Button Click

Hi,
I am trying to simulate a PictureBox.Click event. I have searched these forums and the ones on MSDN with many different combinations of search terms.
However I cannot find anything!
Basically what I am trying to achieve is to fire the picturebox's click event from within my code. What I have read so far seems to indicate that I need to make a call to SendMessage (COM interop?) to actually make windows perform the click.
This is for the compact framework version 1.0.
Any help you can give would be great because this is all very new to me, I'm a web application developer by trade so i'm a fish out of water on this one!
OK, the other method that I am investigating is the use of the mouse_event as demonstrated in this article by Daniel Moth.
However I am struggling to find the namespace Win32Api anywhere in the framework so I'm struggling with that also.
*Update*
I have been able to simulate a click using mouse_event in a call to the coredll using the following code:
Code:
[DllImport("coredll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("coredll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
bool tempVal = SetCursorPos(x, y);
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
however I have one outstanding problem (that I know of!).
I am struggling to capture the corrext X and Y co-ordinates of the control. I have tried many different methods and they all return values of 0 for both axis.
How do you guys do it?
Many Thanks
I haven't answered till now since I don't know .NET
But since you found your way to using native APIs I think I can help you.
This is how I would do it in C/C++:
Code:
RECT wndRect; //this is a structure that contains window top, left, bottom and right coordinates.
GetWindowRect(FindWind(L"[I]window class[/I]", L"[I]window name[/I]"), &wndRect);
x = wndRect.left + 1; //add 1 to window position to make sure the click is inside
y = wndRect.top + 1;
GetWindowRect returns the window position in screen coordinates for top left and bottom right corners.
For FindWindow to work you need to know the class and name of the window you want to find. You can find them using a utility called SPY++ which comes with any Microsoft C++ compiler.
The class is window type (so it will probably be something like 'PictureBox' or 'Image') and window name is most likely blank.
Hope this helps.
Thanks fo your help
I don't know if your code would have done the trick or not but I managed to work my way through the different class definitions to find what i needed.
Code:
int x = selectedButton.PointToScreen(selectedButton.Bounds.Location).X + 2;
int y = selectedButton.PointToScreen(selectedButton.Bounds.Location).Y + 2;
This still doesn't work but I really don't have time to work out why, all I know is that the call to SetCursorPos() returns false. I know the mouse_event code works because if I position the cursor over the Start button it opens the menu.
Time is of an essence so for now I'm just going to have to drop this and pray that I have time to finish this when towards the end of my project.
/me thinks writing my first Mobile 5.0 application in 4 days (I'm a web application developer by trade) was bad planning on the management's fault anyway
Thanks for your input though
use this method signature:
[DllImport("coredll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
int instead of uint or long.
For me it worked.

Help with CeRunAppAtEvent

Hey all,
I'm trying to register an application to run during a Windows Mobile event using CeRunAppAtEvent (from CoreDll.dll). I'm having difficulty getting this to happen.
Here is the syntax for the native method:
Code:
BOOL CeRunAppAtEvent(
TCHAR* pwszAppName,
LONG lWhichEvent
);
Here is the code in my application (C#):
Code:
[DllImport("coredll.dll", EntryPoint = "CeRunAppAtEvent", SetLastError = true)]
private static extern bool CeRunAppAtEvent(string pwszAppName, int lWhichEvent);
private void menuItem1_Click(object sender, EventArgs e)
{
if (CeRunAppAtEvent(@"\Windows\Calc.exe", 3))
{
MessageBox.Show("Event registered!");
}
else
{
MessageBox.Show("Event did not register.");
}
}
Note that I'm using the argument '3' for lWhichEvent, which is based upon this understanding of how lWhichEvent argument works:
Code:
> NOTIFICATION_EVENT_NONE = 0,
> NOTIFICATION_EVENT_TIME_CHANGE = 1,
> NOTIFICATION_EVENT_SYNC_END = 2,
> NOTIFICATION_EVENT_ON_AC_POWER = 3,
> NOTIFICATION_EVENT_OFF_AC_POWER = 4,
> NOTIFICATION_EVENT_NET_CONNECT = 5,
> NOTIFICATION_EVENT_NET_DISCONNECT = 6,
> NOTIFICATION_EVENT_DEVICE_CHANGE = 7,
> NOTIFICATION_EVENT_IR_DISCOVERED = 8,
> NOTIFICATION_EVENT_RS232_DETECTED = 9,
> NOTIFICATION_EVENT_RESTORE_END = 10,
> NOTIFICATION_EVENT_WAKEUP = 11,
> NOTIFICATION_EVENT_TZ_CHANGE = 12,
> NOTIFICATION_EVENT_MACHINE_NAME_CHANGE = 13
I've tried registering Calc and a few other applications unsuccessfully--the program tells me the event registers (so the method call is returning true), yet the applications do not launch upon the event change (plugging into AC power, for example). Any ideas to what I'm doing wrong?
Bump. Any ideas?
Hello shidell
I also found, that not all possible wakeups are possible on every device. I assume it is OEM related and the implementation of these events is not mandatory for WM platform builds.
See also hjgode.de/dev and look for iRunAtEvent and iRunOnEnet. The latter is a workaround for enet detection.
I recently did try to use ON_AC_POWER and it did not work. The event registration was OK but the event was not signaled on AC power connection. I worked around it and changed my code to run on wakeup, which works OK on this particular device (CK61 running WinCE5).
As a workaround, you could go the way I did in iRunOnEnet. Instead of watching the enet connection you have to check the PowerStatus structure for ON AC POWER.
regards
josef
You are right, not every event can be handled with CeRunAppAtEvent and here are the events that have to works on every device:
Code:
Const NONE = 0
Const TIME_CHANGE = 1
Const SYNC_END = 2
Const DEVICE_CHANGE = 7
Const RS232_DETECTED = 9
Const RESTORE_END = 10
Const WAKEUP = 11
Const TIME_ZONE_CHANGE = 12
Good approach will be to check your application's path by using:
Code:
System.IO.File.Exists(<application>)
because for example in my ROM that "calc.exe" is actually "calculator.exe"... and of course CeRunAppAtEvent will return True, because the event handler will be registered no matter file exists or not
Hope this helps.
Best regards,
aDEO

InTheHand Bluetooth - Weird stream problems

I am currently working on my "SciLor's WiMoBlue". The new protocol is ready. Everything works fine, until I send much data at the same time.
For example if I try to send an image in that way:
Code:
Public Sub SendImage(ByVal Image As Bitmap, ByVal Position As Point, ByVal Format As ImageFormat)
Dim PosX, PosY, Width, Height As Byte()
Dim ImageStream As New IO.MemoryStream
Dim ImageLength As Integer
Dim ImageLengthBytes As Byte()
Dim ImageBuffer(MaxChunkSize - HeaderSize - 1) As Byte
PosX = BitConverter.GetBytes(Position.X)
PosY = BitConverter.GetBytes(Position.Y)
Width = BitConverter.GetBytes(Image.Width)
Height = BitConverter.GetBytes(Image.Height)
Image.Save(ImageStream, ImageFormat2ImagingFormat(Format))
ImageStream.Seek(0, SeekOrigin.Begin)
ImageLength = ImageStream.Length
ImageLengthBytes = BitConverter.GetBytes(ImageLength)
SendData(BuildCommand(BaseProtocol.Image, ImageProtocol.Initiate, CombineBytes(PosX, PosY, Width, Height, ImageLengthBytes)))
Thread.Sleep(2000)
Dim DataPos As Integer
For DataPos = 0 To ImageStream.Length - MaxChunkSize - HeaderSize - 1 Step MaxChunkSize - HeaderSize
ImageStream.Read(ImageBuffer, 0, MaxChunkSize - HeaderSize)
SendData(BuildCommand(BaseProtocol.Image, ImageProtocol.Data, ImageBuffer))
'WaitForNextChunk = True
'Do While WaitForNextChunk = True
'Loop
'Thread.Sleep(2000)
Next
ImageBuffer = New Byte(ImageLength - DataPos - 1) {}
ImageStream.Read(ImageBuffer, 0, ImageBuffer.Length)
SendData(BuildCommand(BaseProtocol.Image, ImageProtocol.End, ImageBuffer))
End Sub
SendData:
Code:
If Data.Length > MaxChunkSize Then
MsgBox("Data to long... " & vbNewLine & "SendSize:" & Data.Length & vbNewLine & "MaxSize:" & MaxChunkSize)
Else
If btClient.Connected = True And isRecieving = True Then
btStream.Write(Data, 0, Data.Length)
btStream.Flush()
End If
End If
Recieving Part:
Code:
While isRecieving = True
If btStream IsNot Nothing And btStream.DataAvailable = True Then
Try
Recieved = btStream.Read(myHeader, 0, myHeader.Length)
If myHeader(0) = HeaderIdentifier And myHeader(1) = OtherModeHeader Then
btStream.Read(myDataSize, 0, 2)
DataLength = BitConverter.ToInt16(myDataSize, 0)
myBuffer = New Byte(DataLength - 1) {}
Recieved = 0
Do Until Recieved = DataLength
If btStream.DataAvailable = True Then
Recieved += btStream.Read(myBuffer, Recieved, DataLength - Recieved)
End If
Loop
ExecuteCommand(myHeader(2), myHeader(3), myBuffer)
Else
Debug.WriteLine("WrongData")
Exit While
End If
Catch ex As Exception
Debug.WriteLine(ex.Message)
If Recieved = 0 Then
Exit While
End If
End Try
End If
End While
If I send the image, without Thread.Sleeps (huighe ones). The recieving stream gets weird. The gets btStream.DataAvailable = False forever. If I remove that ckeck, it hangs at the btStream.Read.
I also tried to fix that with waiting for the answer of the server, but the problem doesn't get solved.
Do you have any idea how to fix that problem?. In that speed the image sending is worthless
SciLor

Fullscreen Direct3D not working on Diamond

Hi,
I have a problem running a Direct3D app on full screen on a HTC Diamond: no matter which way I create the Direct3D device, by making a window that covers the full screen, or by creating a fullscreen device, all I see is the background of the window. Nothing rendered in Direct3D is shown.
If I use a window that is, for example, one pixel shorter than the full screen - everything works fine, but "real" full screen doesn't.
The Direct3D examples from the WM6 SDK, which also create a full screen window, fail exactly the same way both on my phone and on another Diamond I've tested, so I assume it's not a problem with my configuration or ROM, but a common one. Also I've found a few similar questions on other forums, mentioning phones like the Touch Pro, but no answers.
To create a fullscreen window I do the following:
g_screenWidth = GetSystemMetrics(SM_CXSCREEN);
g_screenHeight = GetSystemMetrics(SM_CYSCREEN);
g_hWndMain = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
0, 0, g_screenWidth, g_screenHeight, NULL, NULL, hInstance, NULL);
SHFullScreen(g_hWndMain, SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
/* ... */
D3DMPRESENT_PARAMETERS presentParameters;
memset(&presentParameters, 0, sizeof presentParameters);
presentParameters.SwapEffect = D3DMSWAPEFFECT_DISCARD;
presentParameters.Windowed = true;
HRESULT hr = g_d3d->CreateDevice(D3DMADAPTER_DEFAULT, D3DMDEVTYPE_DEFAULT, g_hWndMain, NULL,
&presentParameters, &g_dev);
All the functions succeed, however, nothing gets drawn on the screen besides the background of the window.
The same thing happens when I create a fullscreen device, like below:
// The same window creation stuff...
// ....
presentParameters.BackBufferWidth = g_screenWidth;
presentParameters.BackBufferHeight = g_screenHeight;
presentParameters.BackBufferFormat = D3DMFMT_UNKNOWN;
presentParameters.BackBufferCount = 1;
presentParameters.SwapEffect = D3DMSWAPEFFECT_DISCARD;
presentParameters.Windowed = false;
presentParameters.FullScreen_PresentationInterval = D3DMPRESENT_INTERVAL_DEFAULT;
HRESULT hr = g_d3d->CreateDevice(D3DMADAPTER_DEFAULT, D3DMDEVTYPE_DEFAULT, g_hWndMain, NULL,
&presentParameters, &g_dev);
Again, all the calls seem to succeed, but nothing is visible on the screen. I've tried setting the pixel format explicitly - still nothing is drawn.
But if I change the window in the first example to be one pixel less than the size of the screen, everything is displayed correctly.
Does anyone know why this is happening and whether some solutions for running the app full-screen are possible? As far as I understand, VSync is available only in fullscreen mode, so I'd like to get it working - although one missing line of pixels isn't really visible on the Diamond screen.
And yet another unrelated question: does the graphics chip in the Diamond support render-to-texture? It seems to be not available in Direct3D, but it might still be exposed in OpenGL ES in that case...

Categories

Resources