NETCF - Always on top form but SIP stays on top problem - compact-framework

how can I get rid of that SIP button in there? My form was supposed to be always on top, set via API SetWindowsPOS but that button still sits on top? Obviously, am not using any InputPanel as you can see there...

I am presuming the OS is Windows Mobile 6.5? Below is the code I use to disable the SIP button in 6.5:
public static class SoftInputPanel
{
const uint SIPF_OFF = 0x0;
const uint SIPF_ON = 0x1;
[DllImport("aygshell.dll")]
static extern uint SHFullScreen(IntPtr hwndRequester, uint dwState);
private const uint SHFS_HIDESIPBUTTON = 0x0008;
private const uint SHFS_SHOWSIPBUTTON = 0x0004;
[DllImport("coredll.dll")]
private extern static void SipShowIM(uint dwFlag);
public static void ShowSIP(bool isShow, Control control)
{
SHFullScreen(control.Handle, isShow ? SHFS_SHOWSIPBUTTON : SHFS_HIDESIPBUTTON);
SipShowIM(isShow ? SIPF_ON : SIPF_OFF);
}
}

Related

User32 Windows UI Api on Universal Windows Platform

I don't have a lot of experience on UWP programming and i built an app does some stuff on Bluetooth. Now i have to cary some info through APIs. But somehow "SendMessage" doesnt work. Here is the code i'm using
public static class ApiComm
{
[DllImport("User32.dll")]
public static extern IntPtr FindWindow(String lpClassName, String lpWindowName);
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, int lParam);
public static string DelphiFormClassName = "TFrmMain";//"wsdk_delphi_api_test";
public static string DelphiFormCaptionName = "Deneme";
private static IntPtr FindDelphiForm(string delphiFormClassName, string delphiFormCaptionName)
{
return FindWindow(delphiFormClassName, delphiFormCaptionName);
}
private static IntPtr FindDelphiForm()
{
return FindDelphiForm(DelphiFormClassName, DelphiFormCaptionName);
}
public static int TextToID(string text)
{
int mu = (text == null ? 0 : text.Length);
int result = 0;
for (int i = 0; i < mu; i++)
result = result + (((i + 1) * 256) + (byte)(text[i]));
return result;
}
private const int WM_COMMAND = 0x0111;
private const int StartFrom = 500;
private static int EventID(RemoteDeviceUpdate anEvent)
{
return StartFrom + (int)anEvent;
}
public static void SendInfo(int remoteID, RemoteDeviceUpdate anEvent)
{
IntPtr wP = FindDelphiForm();
if (wP != null && wP != IntPtr.Zero)
{
int eID = EventID(anEvent);
SendMessage(wP, WM_COMMAND, eID, remoteID);
}
}
public static void SendInfo(string remoteID, RemoteDeviceUpdate anEvent)
{
SendInfo(TextToID(remoteID), anEvent);
}
}
when i try SendInfo with another .net projects, it works just fine but with UWP it doesnt (and it doesnt give any error also)
do i have to add packages or something to my project..
any help would be appreciated, thanks.
Derive from this case, you need check if the API available to Windows Runtime apps.
Apps can p-invoke DLLs deployed with the app package. The DLL will run in the app's context and have the same API access as the app itself. See Win32 and COM APIs for an overview of Win32 API available to Windows Runtime apps.
If you just want to build an app does some stuff on Bluetooth. You can do it all with uwp
Bluetooth api. And this is official document. For RFFCOMM, this is uwp code sample that you could refer.

Unity: Preserving static object/data between editor and play

I made offline Waypoints Network generator, which is able to construct waypoints network in editor so we can move or remove the waypoints during the editing process. However I need some way to reference the waypoints network from different objects in play mode and I really like the singleton approach. My idea is:
I have 3 scripts: WNNetwork, WNNetworkObject and WNNetworkData.
WNNetworkData is simple ScriptableObject, which holds the calculated data.
[System.Serializable]
public class WNNetworkData : ScriptableObject {
// Data of waypoints network
public List<WNWaypoint> waypoints = new List<WNWaypoint> ();
public WNKDTree tree = null;
}
WNNetworkObject is MonoBehaviour scripts that is attached to GameObject and it is use to update, re-generate or delete the waypoints network.
public class WNNetworkObject : MonoBehaviour {
#region Public Variables
// Properties of waypoints
public float size = 1f;
public Color color = Color.cyan;
public Color colorSelected = Color.white;
public Color colorLine = Color.white;
public float lineWidth = 0.5f;
public WNWaypoint.GizmosType type = WNWaypoint.GizmosType.CUBE;
// Parameters for network generation
public float maxClusterRadius = 2;
public float neighborsThreshold = 10f;
public bool doNeighborsSimplification = true;
// Others
// public GameObject queryTarget;
#endregion
#region Life-cycle
void Awake () {
DontDestroyOnLoad (this.gameObject);
}
void Start () {
Debug.Log (WNNetwork.data);
}
#endregion
...
}
This is how it's look in inspector editor:
WNNetwork Inspector editor
The last script is WNNetwork, which is basically a wrapper class holding static reference to WNNetworkData and WNNetworkObject, so I can easily access both.
public class WNNetwork {
public static WNNetworkObject root;
public static WNNetworkData data;
...
}
I also created an EditorScript, so I can create all objects from Menu, here is the creation part.
public class CreateWaypointsNetwork {
[MenuItem("GameObject/Create Other/Waypoints Network")]
public static void Create ()
{
WNNetworkData data = ScriptableObject.CreateInstance <WNNetworkData> ();
GameObject go = new GameObject ("WaypointsNetwork", new System.Type[]{typeof(WNNetworkObject)});
WNNetworkObject root = (WNNetworkObject) go.GetComponent<WNNetworkObject> ();
WNNetwork.data = data;
WNNetwork.root = root;
AssetDatabase.CreateAsset (data, "Assets/WaypointsNetworkData");
AssetDatabase.SaveAssets ();
EditorUtility.FocusProjectWindow ();
Selection.activeObject = go;
}
}
The thing is, when I create the Waypoints Network everything works in editor, every object seems to be successfully created and I can edit the waypoints. But as soon as I hit the play button, the WNNetwork is reset and all static variables are equal to null. The Network itself seems to be preserved, because every waypoint still have reference to all its neighbours, but I cannot access the data.
I know I am doing something terrible wrong, but I'm unable to determine what, I'm still not so familiar with Unity.
Thanks for any help.
Simply unity doesn't serialize static fields (even if they are of a serializable type).
When you switch from editor to play mode you are deserializing/serializing data, so you will end up losing everything stored into static fields.

terminate the BB 10 app on Alert button ok pressed

I have a socket connection App in my BB 10 cascades, when ever socket connection is closed i need to show a dialog box and when pressed on OK button app need to close.
please find my code here...
void SocketBase::writeLine(QTcpSocket *socket, const QString &line)
{
if (socket->state() != QAbstractSocket::ConnectedState)
{
onOkAlert("Please check your internet connection and restart the app again");
}
}
void SocketBase::onOkAlert(const QString &message)
{
dialog = new SystemDialog(tr("OK"), 0);
dialog->setTitle(tr("Alert"));
dialog->setBody(message);
bool success= QObject::connect(dialog,SIGNAL(finished(bb::system::SystemUiResult::Type)),
this,
SLOT(onDialogFinishe(bb::system::SystemUiResult::Type)));
if(success){
dialog->show();
}
}
and I also added at top of my class,
using namespace bb::data;
using namespace bb::cascades;
using namespace bb::system;
SystemDialog *dialog;
and my socketBase.h is like,
class SocketBase: public QObject{
Q_OBJECT
public:
SocketBase(const QString &ipAddr, const ushort port) :
mIP(ipAddr), mPort(port) {
mRunThread = false;
}
enum Identity {
BAD_IDENTITY, SERVER, CLIENT
};
virtual void startThread() = 0;
virtual void stopThread() = 0;
virtual Identity getIdentity() = 0;
Q_INVOKABLE void showDialog(int id);
void onOkAlert(const QString &message);
private slots:
void onAPPFinished();
void onDialogFinishe(bb::system::SystemUiResult::Type);
}
here is the app termination code
void SocketBase::onDialogFinishe(bb::system::SystemUiResult::Type)
{
qDebug()<<" dialog->result():::"<<dialog->result();
if(dialog->result()==2)
{
qDebug()<<"::: Terminate App :::";
bb::Application::exit(0);
}
}
what is wrong in my code, please help!!!

screen tinter

with the help of the stackoverflow community i have designed an app that colors the screen, and makes it look like you are wearing different color glasses.
i would also like to add the functionality of instead of coloring the whole screen, ONLY coloring the background of a document exactly like this program does:
http://www.thomson-software-solutions.com/html/screen_tinter.html
anyone have any clue how to do this in vb.net?
That's a pretty simple trick, it just replaces the system color that's used for window backgrounds. You'd change it by P/Invoking the SetSysColor() API function. Here's a sample Windows Forms app that demonstrates the technique. Start a new WF app and drop a button on the form. Then paste this code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
int oldcolor;
public Form1() {
InitializeComponent();
oldcolor = GetSysColor(COLOR_WINDOW);
this.FormClosed += new FormClosedEventHandler(Form1_FormClosed);
this.button1.Click += new EventHandler(button1_Click);
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e) {
int element = COLOR_WINDOW;
SetSysColors(1, ref element, ref oldcolor);
}
private int Color2COLORREF(Color color) {
return color.R | (color.G << 8) | (color.B << 0x10);
}
private void button1_Click(object sender, EventArgs e) {
int element = COLOR_WINDOW;
int colorref = Color2COLORREF(Color.NavajoWhite);
SetSysColors(1, ref element, ref colorref);
}
private const int COLOR_WINDOW = 5;
[DllImport("user32.dll")]
private static extern bool SetSysColors(int one, ref int element, ref int color);
[DllImport("user32.dll")]
private static extern int GetSysColor(int element);
}
}
Offtopic a bit, but you can change Word to default to "White on Blue". Blue background, white text.

C# Custom PrintDialog PInvoke DevMode Question

According to the following page:
http://msdn.microsoft.com/en-us/library/ms646964(VS.85).aspx
underneath the first graphic, "If the user clicks the OK button, PrintDlg returns TRUE and the PRINTDLG structure to return informmation about the user's selection".
In this case, my custom print dialog is nearly working, but I'm trying to extract the information about printer name, orientation, etc... My understanding is that in order to retrieve the printer name, I need to examine the hDevMode value from the PRINTDLG structure to see the printer name. Is there a function that will allow me to extract that info?
My code is like (where pdlg is my defined instance of the PRINTDLG structure):
bool f = false;
try
{
f = PrintDlg(ref pdlg);
DEVMODE dm = pdlg.hDevMode;
int k = 0;
} catch (Exception ex)
{
// hopefully it doesn't fail
}
If someone has any pearlsof wisdom out there, I would sure appreciate any tips.
The following shows how to extract the printer name and driver. The key is to do a GlobalLock on hDevNames, Marshal.PtrToStructure it into the CLR version of the struct, and then access its content. Remember to GlobalUnlock when done.
You could do something similar with hDevMode, which will get you information about the printer metrics and setup. You can find a C# declaration of the DEVMODE struct here.
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication3 {
class Program {
// Win32 struct declarations
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto, Pack = 1)]
[System.Runtime.InteropServices.ComVisible(false)]
internal class PRINTDLG {
public Int32 lStructSize;
public IntPtr hwndOwner;
public IntPtr hDevMode;
public IntPtr hDevNames;
public IntPtr hDC = IntPtr.Zero;
public Int32 Flags;
public Int16 FromPage = 0;
public Int16 ToPage = 0;
public Int16 MinPage = 0;
public Int16 MaxPage = 0;
public Int16 Copies = 0;
public IntPtr hInstance = IntPtr.Zero;
public IntPtr lCustData = IntPtr.Zero;
public IntPtr lpfnPrintHook;
public IntPtr lpfnSetupHook = IntPtr.Zero;
public IntPtr lpPrintTemplateName = IntPtr.Zero;
public IntPtr lpSetupTemplateName = IntPtr.Zero;
public IntPtr hPrintTemplate = IntPtr.Zero;
public IntPtr hSetupTemplate = IntPtr.Zero;
}
[StructLayout(LayoutKind.Sequential)]
public class DEVNAMES {
public short wDriverOffset;
public short wDeviceOffset;
public short wOutputOffset;
public short wDefault;
}
// import PrintDlg, GlobalLock and GlobalUnlock
[DllImport("comdlg32.dll", CharSet = CharSet.Auto)]
private static extern bool PrintDlg([In, Out] PRINTDLG lppd);
[DllImport("kernel32.dll")]
private static extern IntPtr GlobalLock(IntPtr hMem);
[DllImport("kernel32.dll")]
private static extern bool GlobalUnlock(IntPtr hMem);
static void Main(string[] args) {
// show the printer dialog box
PRINTDLG pd = new PRINTDLG();
pd.lStructSize = Marshal.SizeOf(pd);
PrintDlg(pd);
// here's the meat -- extract the printer information
// out of pd.hDevNames...
DEVNAMES devNames = new DEVNAMES();
// lock hDevNames into memory and get a pointer to it
IntPtr pDevNames = GlobalLock(pd.hDevNames);
// marshal into a DEVNAME struct
Marshal.PtrToStructure(pDevNames, devNames);
// pull out the device and driver strings; hopefully not much of
// that in DEVMODE
string sDevice = Marshal.PtrToStringUni((IntPtr) (
pDevNames.ToInt32() +
devNames.wDeviceOffset * Marshal.SystemDefaultCharSize));
string sDriver = Marshal.PtrToStringUni((IntPtr) (
pDevNames.ToInt32() +
devNames.wDriverOffset * Marshal.SystemDefaultCharSize));
string sOutput = Marshal.PtrToStringUni((IntPtr) (
pDevNames.ToInt32() +
devNames.wOutputOffset * Marshal.SystemDefaultCharSize));
// done -- release the global memory handle
GlobalUnlock(pd.hDevNames);
}
}
}