I have a problem in setting controls in a Win32 application.
When I use SendMessage to set a text string in a static control I get error number 120 which translated means: "This function is only valid in Win32 mode."
Here's the background:
I'm using Visual Studio 2005, I've installed the Windows Mobile 5 SDK.
The project was created using the New Project Wizard, with the following settings:
Visual C++/Smart Device
Win32 Smart Device Project
Platform SDK is: Windows Mobile 5.0 Pocket PC SDK
Windows application
I've added a dialog template resource and can bring up a dialog based on that resource. It contains a static control that I can read the text from, but attempting to set the text gives me the above error.
The relevent code (within the WM_INITDIALOG message handler) is:
Code:
char buffer[100];
HWND hCtrl = ::GetDlgItem(hDlg, IDC_TITLE);
LRESULT result = ::SendMessage(hCtrl, WM_GETTEXT, (WPARAM)80, (LPARAM)buffer);
This works, I get the correct text (ie the text I have placed into the static control using the dialog template editor) copied into the buffer. What follows is:
Code:
buffer[0] = 'A'; // Just to set up a different string
result = ::SendMessage(hCtrl, WM_SETTEXT, (WPARAM)0, (LPARAM)buffer);
if (result == 0)
{
LPVOID lpMsgBuf;
DWORD error = ::GetLastError();
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
::MessageBox(NULL, (LPCTSTR)lpMsgBuf, (LPCWSTR)"LError", MB_OK | MB_ICONINFORMATION);
::LocalFree(lpMsgBuf);
}
The attempt to set the changed text string fails (ie result == 0), and the last error is 120, which is translated to the error message above.
This works the same in both the Windows Mobile 5 emulator, and if I run it on my Atom.
What does this mean? How could it be anything other than Win32 mode?
Is there a function or something I have to call to put it into Win32 mode?
Or is it a project setting in VS2005 that I haven't been able to find?
I'd very much appreciate any help on this.
Peter
Your build target was a PPC 2003 variant for this project, correct? If so (and I'm assuming that it is so because you mention trying this on the PPC emulator), then you are most certainly not in Win32 mode, rather you are targeting WinCE. To target win32, you need to go into configuration manager and change your target at which point your program will no longer run on PPC.
More to your problem: I don't believe that you can dynamically change dialog static control properties through messaging on WinCE. I may be wrong on this here though too....
Related
I'm creating a project as a dll. Can anybody tell me how to go about debugging it. I attach it to the remote process "services.exe" but any breakpoints I put, dont hit and display an exclamation mark, saying that no executable code exists at that point..
How do you guys debug ur DLLs??
be sure that services.exe is the correct process
bye
Let me explain a bit. Actually I'm trying to write a WinMob service (This is my first time writing a service dll, infact, first time writing a dll).
I created a dll with the DLL_PROCESS_ATTACH case in the ul_reason_for_call calling a SPC_init function (exported using __declspec(dllexport)).
Moreover, I added these entries to the registry:
[HKEY_LOCAL_MACHINE\Services\ShantzABC]
"Order"=dword:00000009
"Index"=dword:00000000
"Prefix"="SPC"
"Keep"=dword:00000001
"Dll"="ShantzABC.dll"
"FriendlyName"="ShantzABC"
But the service didn't load. Then I added the line "services load ShantzABC" to the deployment options of my VS2005 project. Now, on pressing F5, the service loads (I know because I put a MessageBox() inside the SPC_init, which is now displayed on screen) BUT:
1. I can't see the ShantzABC.dll loaded in Remote Process Viewer tool (seeing for services.exe)
2. Moreover, I can't hit any breakpoints in my project, even the one kept on the MessageBox() line. (Though now they have stopped giving the error "not an executable line" that they were giving earlier)
Actually I'm trying to start a project which could benefit greatly if it was a service instead of me writing an exe for it..
So, any pointers??
EDIT: added a part of the code:
Code:
#include "stdafx.h"
#include "ShantzABC.h"
#include <windows.h>
#include <commctrl.h>
HINSTANCE g_hInst;
// This is an example of an exported function.
__declspec(dllexport) HRESULT SPC_init(void)
{
HRESULT result;
MessageBox(NULL, TEXT("initCtrl"), TEXT("INIT"), MB_OK);
result = S_OK;
return result;
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
HRESULT result;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//save instance handle
g_hInst = (HINSTANCE) hModule;
result = SPC_init();
MessageBox(NULL, TEXT("initCtrl"), TEXT("main"), MB_OK);
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
1. implements all the exported functions for service:
Init, Open, Close, Deinit, IOControl, Read, Seek, Write also if empty (just return 0)
2. instead to use F5 to debug it, try to deploy the dll and attach the process to debug it: Debug > Attach to process.... (vs2005's menu)
i hope this help you
Could you please direct me to an SW development environment, which documents the above functions, Reg_Key meanings etc. sort of a reference guide? What compilers/linkers do you guys use ?
crino said:
1. implements all the exported functions for service:
Init, Open, Close, Deinit, IOControl, Read, Seek, Write also if empty (just return 0)
2. instead to use F5 to debug it, try to deploy the dll and attach the process to debug it: Debug > Attach to process.... (vs2005's menu)
Click to expand...
Click to collapse
I implemented all the functions and just returned 1. (didnt return 0 because read on a msdn blog that returning 0 form dllmain or xxx_Init will unload the dll)
But again on attaching to services.exe, its not loading my dll(or unloads it soon after loading). (Dll is kept in \windows)
So, cant find the dll in the modules window and so cant load the symbols for it in order to debug it..
Hi All
Ive found this code , can you tell me what is this language
It is a sample to be able to change automatically themes in the Pocket PC
Can you help me ,making an exe with theme in parameters if possible ?
HKEY hKey;
LONG lRet;
TCHAR szCmdLine[MAX_PATH+1];
TCHAR* pszFile = _T("\\Windows\\Fire.tsk"); // The theme file
//
// Set the theme
//
lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0,
&hKey);
if(ERROR_SUCCESS == lRet)
{
RegDeleteValue(hKey, _T("UseStartImage"));
wcscpy(szCmdLine, _T("/safe /noui /nouninstall /delete 0 "));
wcscat(szCmdLine, pszFile);
if:CreateProcess(_T("\\Windows\\wceload.exe"),
szCmdLine,
NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
{
::WaitForSingleObject(pi.hProcess, INFINITE);
RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszFile,
sizeof(TCHAR) * (wcslen(pszFile) + 1));
RegCloseKey(hKey);
}
//
// Broadcast the update today message
//
::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
}
the last line code is named : The Magical touch
I've tried near the same with Mortscript but it doesn't work always .
seems to work only when there is a reg key UseStartImage (this one deleted first in this program)
I don't understand the value &pi in the call of wceload
anyone can help me ?
C++
The language is C++
For details of CreateProcess see http://msdn.microsoft.com/en-us/library/ms939168.aspx
The final parameter is a pointer to a PROCESS_INFORMATION structure that will be filled in with details of the created process. Embedded C++ version 3.0 or 4.0 should compile it, but you will have to add the code to that of a skeleton project. Alternatively use Visual Studio 2005 onwards.
stephj said:
The language is C++
For details of CreateProcess see http://msdn.microsoft.com/en-us/library/ms939168.aspx
The final parameter is a pointer to a PROCESS_INFORMATION structure that will be filled in with details of the created process. Embedded C++ version 3.0 or 4.0 should compile it, but you will have to add the code to that of a skeleton project. Alternatively use Visual Studio 2005 onwards.
Click to expand...
Click to collapse
thank you man
Hi
i begin in level of system of WM5.
I have make some software in language C for WM5/WM6.
I search help for recover system information (network GPRS or WIFI, enumerate Available Access Points ,signalStrength,...),
if you know api for that thank you
Sorry for my english i say it is little poor
Hi
I have find solution i used i post solution if you are interessted:
pQueryOid = (PNDISUIO_QUERY_OID) Buffer;
pQueryOid->Oid = OID_802_11_BSSID_LIST;
pQueryOid->ptcDeviceName = /* your AdapterName*/
//-------------------------------------------------------------------------------------------------------------------------------------------------------
//creates, opens, or truncates a file, COM port, device, service, or console. It returns a handle that you can use to access the object.
handleDevice = CreateFile(NDISUIO_DEVICE_NAME,
GENERIC_READ|GENERIC_WRITE, 0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
(HANDLE) INVALID_HANDLE_VALUE);
if (handleDevice == INVALID_HANDLE_VALUE)
return NULL;
//sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.
if (DeviceIoControl(handleDevice,
IOCTL_NDISUIO_QUERY_OID_VALUE,
(LPVOID) pQueryOid,
8192,
(LPVOID) pQueryOid,
8192,
&bytesWritten,
NULL))
Hi Guys/Girls,
I'm a new to android development and today I've run in quiet strange issue.
I have onClick action for Button which call function to read and parse file.
When I click on button in debugger error appeared and my action failed:
Code:
11-28 21:57:50.838: WARN/System.err(309): Error: /lib/eng-srb.csv (No such file or directory)
In eclipse (Normal Java development) relative paths work as well.
In ADT this seems not to work.
I've tried various combinations of location but without success.
This is code I'm using:
Code:
File f = new File("lib/eng-srb.csv");
FileInputStream fstream = new FileInputStream(f);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
Any idea ?
Thx,
Vukasin
P.S.
Google didn't help me a lot on this issue.
Solution
finally Google helped
Code:
h**p://android-er.blogspot.com/2010/07/display-text-file-in-resraw_01.html
I used this code:
Code:
mWebViewVertreungsplan = (WebView)findViewById(R.id.webViewVertretung);
mWebViewVertreungsplan.setVisibility(View.VISIBLE);
mWebViewVertreungsplan.setWebViewClient(new WebViewClient());
// Enable Javascript
WebSettings webSettings = mWebViewVertreungsplan.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebViewVertreungsplan.loadUrl("Username: Pasword @ domain. com");
On the on some devices it works, but on others it wont work. I geht the error 401 unauthorized.
Funny enough i am working on a project that has to do with a "substitution plan" as well (dunno what the correct english translation is) xD
You have to put the credentials inside the url header, and they have to be Base64 encoded
I use jsoup library to read the values from a pw protected site, so putting things into header is done differently, but same principle:
[...]Jsoup.connect("domain.com").header("Authorization", "Basic " + encodedString).post()
encodedString is done like that:
String text ="unamewd";
byte[] data = null;
data = text.getBytes("UTF-8");
encodedString = Base64.encode(data, Base64.DEFAULT);
So only thing you would have to google is how to set url header for webview