|
Include the following in your code:
[DllImport("user32.dll")]
public external void PostQuitMessage(int returnVal);
Jeff
|
|
|
|
|
After Updating the code and running my observations are that my MainForm does not show anymore and the app just exits (Runs fine after removing the following bit of code).
[System.Runtime.InteropServices.DllImport("user32.dll")]<br />
public static extern void PostQuitMessage(int returnVal);<br />
<br />
protected override void WndProc(ref Message m)<br />
{<br />
switch (m.Msg)<br />
{<br />
case 0x0112:<br />
<br />
switch (m.WParam.ToInt32())<br />
{<br />
case 0xF140:<br />
case 0xF170:<br />
<br />
return;<br />
}<br />
<br />
break;<br />
<br />
case 0003:<br />
PostQuitMessage(0);<br />
return;<br />
}<br />
<br />
base.DefWndProc(ref m);<br />
}
|
|
|
|
|
Put in some breakpoints and find the path that the code is taking to exit your application. Then post the results here so we can get a better idea of what is going on. Why do you call base.DefWndProc instead of base.WndProc?
Jeff
|
|
|
|
|
Sukhjinder_K wrote: being very new to Windows Programming
Sukhjinder_K wrote: I'm writing a MediaPlayer
very new and writing a MediaPlayer
Sukhjinder_K wrote: So your thoughts...
My thought is, that does not compute.
|
|
|
|
|
I have programmed in Java a lot. So I'm just new to Windows Programming and C# and have never done Windows Message handling (or anything having HWND in it) before. I was looking for a Free Media Player which had what I needed, I couldn't find one. So I decided to build one on my own. And I chose C# to learn a new Language/Platform.
Thanks for your thoughts Mike...
|
|
|
|
|
Did you check it switching to appropriate Case block?
|
|
|
|
|
Thanks Everybody for your help. Here is the Solution
const int WM_SYSCOMMAND = 0x0112, SC_SCREENSAVE = 0xF140, SC_MONITORPOWER = 0xF170;<br />
protected override void WndProc(ref Message m)<br />
{<br />
if( m.Msg == WM_SYSCOMMAND )
{<br />
if( m.WParam.ToInt32() == SC_SCREENSAVE || m.WParam.ToInt32() == SC_MONITORPOWER )<br />
{
return;<br />
}<br />
} <br />
base.WndProc(ref m);<br />
}
|
|
|
|
|
Hi All,
I am writting a C# project in which am using Browser Control. The object of this project to read values of JavaScript's variables values on the current page ,and add those values to ListBox control. Can anybody show me how to do this. Please help if you can I need to do this ASAP for my job.
Thanks,
Asif
|
|
|
|
|
A.Asif wrote: am using Browser Control.
There are many articles on MSDN and I imagine some on CodeProject as well for using the Browser Control in C#, try starting there.
|
|
|
|
|
I did research almost erevry site including microsoft but found no luck to my perticullar problem.
So please help if you can
Thanks,
Asif
|
|
|
|
|
Add a reference to the MSHTML.dll and cast to the DOM types as explained in some document you read (you said you did them all). Then simply use the DOM to get the values.
xacc.ide
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
Thanks for your help! I am trying DOM but don't seems to work for me, can you please show me or send me some sytax how to get this values. I'll really apreciate your help.
Thanks
Asif
|
|
|
|
|
Hi Guys. I have a very stupid/simple question for you. I have two forms in my project, one a logon form called from my main form. When the user enters his username on the logon form I want to move the username into a label on my mainform. Can somebody please advise me on how to do this?
Thanks in advance.
|
|
|
|
|
|
I am using backgroundworker thread in my application... i need to track each background worker and need to show the status in a datagrid ...
my application is used for database administrating ...
backups
restore
attaching
so various activities are going in different background workdes and their status need to show on a datagrid ... and each row in the datagrid should updated correctly ....
can someone write a small piece of code ....
thankzzzzzzzz
A123-B321
|
|
|
|
|
Have your background threads fire events for different states. Then your UI thread can listen to those events and respond appropriately.
You can also poll the status of the background threads by keeping track of the object reference, however, the event model is easier.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
You can use ProgressChanged event of the backgroundworker component to report progress
|
|
|
|
|
can you just write a small piece of code to update the activities into a datagridview ....
i mean, if i am click on a button control to run backup activity and it will update into a datagrid row as dbname, backup going on and when i click again on same button control and it need to appear in the grid as second row ... with dbname, backup going on ... .and when the first thread completes, the grid first row need to update with dbname, backupcompleted ... how could i do this ... please write a small piece of code ...
A123-B321
|
|
|
|
|
Hi I am writing an application which retrieves your outlook contacts.
Right now I am able pop up the contacts window of the Outlook, but I want the specific fields to be printed in my checkedlistbox
I used the following code to pop up the contacts window. Now I want to get he name+last name and the fax number to printed in my chckedlistbox. But I cant find the object under OutlookItems to print the whole contacts list. Any Help?
try
{
Outlook.Application oApp = new Outlook.Application();
// Get the NameSpace information.
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
// Log on by using a dialog box to choose the profile.
oNS.Logon(System.Reflection.Missing.Value, System.Reflection.Missing.Value, true, true);
// Get the default Contacts folder.
Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);
// Get the Items collection from the folder.
Outlook.Items oItems = (Outlook.Items)oContacts.Items;
// Get the first contact item in the Items collection.
Outlook.ContactItem oCt = (Outlook.ContactItem)oItems.GetLast();
string faxNum;
faxNum = oCt.BusinessFaxNumber.Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "");
this.txtRecipientFax.Text = faxNum;
// Display the contact.
//oCt.Display(true);
|
|
|
|
|
s3rro wrote: But I cant find the object under OutlookItems to print the whole contacts list.
They hide that information in the documentation[^]
|
|
|
|
|
I read the document.
I can get the first/last contact. I tried most of them to list the whole Outlook Contacts, list none worked, thats why i asked it here.
Thanks
|
|
|
|
|
s3rro wrote: I tried most of them to list the whole Outlook Contacts, list none worked
I have no idea what that means ????
|
|
|
|
|
Ok,
When i run the code with getLast or getFirst "(Outlook.ContactItem)oItems.GetLast();" everything is good, it pops up Outlook contacts window with the last contact in the list. But you are not able to go up and down on your contacts list.
Normally when you open the contacts window from the Outlook you are able go up/down to check the other contacts.
Now i am looking for the object to view the "main outlook contacts window" or a way to print the whole outlook contacts to a textbox (with whatever i need from the contacts name+lastname phonenumbers) I have in my application.
|
|
|
|
|
s3rro wrote: Ok,
When i run the code with getLast or getFirst "(Outlook.ContactItem)oItems.GetLast();" everything is good, it pops up Outlook contacts window with the last contact in the list. But you are not able to go up and down on your contacts list.
Normally when you open the contacts window from the Outlook you are able go up/down to check the other contacts.
Now i am looking for the object to view the "main outlook contacts window" or a way to print the whole outlook contacts to a textbox (with whatever i need from the contacts name+lastname phonenumbers) I have in my application.
I have no idea what you mean as I have not read the documentation. But, I would image that it would require some iteration to get every single contact from the address book.
I would think something like:
for(int i = 0; i < (oItems.Items.Count; i++)
{
Console.WriteLine(string.format("Contact {0}'s name is: {1}", i.ToString(), oItems.Items[i].ContactName));
}
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
s3rro wrote: But you are not able to go up and down on your contacts list.
What does that mean? State your problem specifically, can you do that?
|
|
|
|