I'm trying to hide the incoming call window, but it's not working.
I declare the functions
Public Declare Function ShowWindow Lib "Coredll" (ByVal hWnd As IntPtr, ByVal iVisible As Integer) As Boolean
Public Declare Function FindWindow Lib "Coredll" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Then call
ShowWindow(FindWindow("", "Phone - Incoming"), 0)
But the window is still there. And yes the window title is correct. I've been trying to debug for over an hour. I don't get any errors it just doesn't work. Any help is greatly appreciated.
Related
Hello friends,
First off, please check below code. Well, I am developing printing functionality from the windows mobile device using vc++. (I am novice to the vc++ ). For printing, we are using third party DLLs. Below are important snippet required to explain the complete picture. Currently, the problem I am more concerning is printing multiple pages. For this, we have API and everything. While printing using “mpPreviewDialog” API (provided by third party in form of DLL) and when it recognize more than one pages required, it raises/passes “MP_EVENT_REQ_NEW_PAGE” message from printing library, ie mpPreviewDialog itself, to the handle hWnd of “mpPreviewDialog(hWnd,__)”. Now, to handle this message, we have put all logic portion in one class which is inherited from CWnd so that we can override “DefWindowProc” function to achieve our goal. But while I run the application and command print for multiple page, it only prints the first page perfectly and then just get hanged. Thus, it fails to handle the “MP_EVENT_REQ_NEW_PAGE” message of “DefWindowProc” function. What all I need is to handle this message and execute the case MP_EVENT_REQ_NEW_PAGE: while printing and multiple page required. Because in this case it issues the message but appropriate case never get executed. I hope you got my point. Please let me know how to solve this. Am I missing something? Thank you very much for your time in advance.
class CFxPrinterWnd : public CWnd
{
DECLARE_DYNCREATE(CFxPrinterWnd)
public:
CFxPrinterWnd(); // protected constructor used by dynamic creation
virtual ~CFxPrinterWnd();
public:
#ifdef _DEBUG
virtual void AssertValid() const;
#ifndef _WIN32_WCE
virtual void Dump(CDumpContext& dc) const;
#endif
#endif
protected:
DECLARE_MESSAGE_MAP()
public:
int PrintReport(HWND hwnd, int flg);
protected:
virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
};
Int CFxPrinterWnd:rintReport (HWND hWnd, int flg)
{
_______
This contains “mpPreviewDialog” API call which starts printing and issue “MP_EVENT_REQ_NEW_PAGE” message if more than one page required.
}
LRESULT CFxPrinterWnd:efWindowProc(___,___,___)
{
Switch (message)
{
___
Case MP_EVENT_REQ_NEW_PAGE: //This debug point never get focused while printing and new page required.
___This point is never get executed
___
}
}
Button1 Click Event
{
hWnd = ::FindWindow(NULL, _T(“del”));
CFxPrinterWnd wnd;
Wnd.Create(_______________________);
Ret = wnd.PrintReport(hWnd, 0);
___
___
mpPreviewDialog (hWnd____); //This is the printing API where MP_EVENT_REQ_NEW_PAGE message get raised while printing if new page
//required.
wnd.DestroyWindow();
}
---
Kind Regards,
Sachin Patel
Hi guys,
Anyone know how to do this:
I open Form2 when a button is clicked on Form1. To return back to Form1 I have a button to do so on Form2. However, is it possible to return back to Form1 automatically after Form2 has displayed for a set amount of time - lets say 2 seconds? This way I could do away with the button on Form2 - which is my goal.
Thanks much, magohn
Drop a timer from the tool box on to Form2 and set its interval to 2000 (2 sec). Then insert the following code into the Form.Activated() and Timer.Tick() events
private void Form2_Activated(object sender, EventArgs e)
{
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
this.timer1.Enabled = false;
this.Close();
}
Thank you SO much...
Thanks again stephj - I modified your code a little as I needed Form2 to be "re-useable" and repro the same action over and over. Thanks!
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Timer1.Enabled = False
Me.Hide()
Timer1.Enabled = True
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
End Sub
I did think afterwards that my example was a bit resource hungry as the Form.Close() method actually destroys the form rather than 'deactivate' it. I threw it together as a quick test, just to prove the point.
Glad it all works.
"I love it when a plan comes together." John "Hannibal" Smith
Hi,
I try to install a Keyboard Hook to get volume key presses in .NET 3.5.
But it fails. Does someone know how to do it?
This is my VB .NET code:
Code:
Imports System.Runtime.InteropServices
Public Delegate Function HookCallback(ByVal nCode As Integer, ByVal wParam As IntPtr, ByVal lParam As intptr) As Integer
Public Class Form1
<MarshalAs(UnmanagedType.FunctionPtr)> _
Private callbackKeyboard As HookCallback
Private Shared hHookKeyboard As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If hHookKeyboard.Equals(0) Then
callbackKeyboard = New HookCallback(AddressOf KeyboardHookProc)
hHookKeyboard = WinApi.SetWindowsHookEx(WinApi.WH_KEYBOARD_LL, callbackKeyboard, WinApi.GetModuleHandle(Nothing), 0)
If hHookKeyboard.Equals(0) Then
MessageBox.Show("Keyboard Hook Failed:" & vbCrLf & hHookKeyboard.ToString() & vbCrLf & Marshal.GetLastWin32Error(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
End If
End If
End Sub
End Class
'API Functions
Public Class WinApi
Public Const WH_KEYBOARD_LL As Integer = 13
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
<DllImport("coredll.dll")> _
Public Shared Function SetWindowsHookEx( _
ByVal idHook As Integer, ByVal HookProc As HookCallback, _
ByVal hInstance As IntPtr, ByVal wParam As Integer) As Integer
End Function
<DllImport("coredll.dll")> _
Public Shared Function GetModuleHandle(ByVal mod2 As String) As IntPtr
End Function
<DllImport("coredll.dll")> _
Public Shared Function CallNextHookEx( _
ByVal idHook As Integer, ByVal nCode As Integer, _
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Integer
End Function
End Class
glad to claim not vb knowlege at all but I can advice you to search
for c# solutions as everything which can be don in c# can be don as
far as I know in vb.net even if the syntes is horrid
thing is most people who you want to get advice from would never
use vb but if you read their stuff you can with a bit of skill convert it
from c# to vb.net even if it makes baby jesus cry
Well, this Code is inspired by C# code from here.
I know that most .NET developers use C# and not VB so I searched for C# code too. I've already used keyboard hooks in desktop apps but this does not work for .NET CF.
Very strange, I tried the same code in C# and it worked!
So I'll write my app in C#
Whatever language you have written the code in should not make any difference. Take the C# generated .EXE file or .DLL that works, and load it into RED GATE's .NET Reflector.
http://www.red-gate.com/products/reflector/
A freeware download, just agree to the disclaimer etc.
Load your program in it and navigate down until the code appears in the main window. It will show you the C# code that was used to create it. It won't know the variable names but it will replace them with int1,int2,string1,float1 etc.
Here's the clever bit, use the drop down box to switch the language to VB, and it will display the VB code to do the same job. You should be able to spot the difference in the code compared to your own VB original.
I am trying to get the cellid from a windows phone 7 program and the code I am using gives me an error when I call the RIL_Initialize function. The code it the standard c# that I have found in several places that everyone seems to be using.
When I try to run this code, I get an exception on the RIL_Initialize.
{"Attempt to access the method failed: CellInfo.RIL.RIL_Initialize(System.UInt32, CellInfo.RIL+RILRESULTCALLBACK, CellInfo.RIL+RILNOTIFYCALLBACK, System.UInt32, System.UInt32, System.IntPtr&)"}
Code:
public static string GetCellTowerInfo()
{
// initialise handles
IntPtr hRil = IntPtr.Zero;
IntPtr hRes = IntPtr.Zero;
// initialise result
celltowerinfo = "";
// initialise RIL
hRes = RIL_Initialize(1, // RIL port 1
new RILRESULTCALLBACK(rilResultCallback), // function to call with result
null, // function to call with notify
0, // classes of notification to enable
0, // RIL parameters
out hRil); // RIL handle returned
....etc.
In my Android application, most of the code and logic is in C++. The C++ code is built as a dynamic library. My Application class loads this native library. In the native library, I want to catch different unix signals that are raised by the OS. I have tried, but unable to trap them.
In the native library, I have done the following :
C++:
void SignalHandler (int signal)
{
__android_log_print(ANDROID_LOG_INFO, TAG, "SignalHandler");
__android_log_print(ANDROID_LOG_INFO, TAG, "signal = %d", signal);
// Do something
}
// Will be called from MainActivity.onCreate()
void NativeFunction (JNIEnv* env, jobject obj) (
JNIEnv* env,
jobject /* this */) {
__android_log_print(ANDROID_LOG_INFO, TAG,"NativeFunction ");
__android_log_print(ANDROID_LOG_INFO, TAG, "Registering for signals...");
if (signal(SIGTERM, SignalHandler) == SIG_ERR)
__android_log_print(ANDROID_LOG_INFO, TAG, "Registering for SIGTERM failed!");
if (signal(SIGINT, SignalHandler) == SIG_ERR)
__android_log_print(ANDROID_LOG_INFO, TAG, "Registering for SIGINT failed!");
__android_log_print(ANDROID_LOG_INFO, TAG, "Successfully registered for signals!");
}
I swiped up from the recents screen or closed the Activity by pressing the Back button, but didn't get any termination signals (lifecycle callbacks of the Activity were called - as expected).
The question is, should I be writing signal handlers to handle these (SIGINT and SIGBREAK) signals? I have only tested these two ways (swipe up and back button press), but there are many ways for Android to terminate an app. Will I ever get SIGTERM, SIGINT or other signals (which expects the application to exit) in the Android environment? I haven't found anything (so far) in the docs.