|
in that case, set the IsMdiContainer to true and set the MdiParent property of the myMDIChild class to the new created form.
This should work.
Fred.
There is no spoon.
|
|
|
|
|
let me understand..
my main form is frmMain
my child form is frmChild
the active dialog is frmDialog
a user clicked a button which shows a frmDialog and when the user click on the button on the frmDialog it should close it and open frmChild within the container (frmMain)
so you want to say in frmDialog i should have this:
frmData frmChild = new frmData();
frmChild.MdiParent = frmMain();
frmChild.Show();
I tried that but getting this error:
dialog_form.cs(258): 'Ezi_Life.frmMain' denotes a 'class' which is not valid in the given context
|
|
|
|
|
Is this what you're looking for?
in MDI main form:
private void menuItem1_Click(object sender, System.EventArgs e)
{
DialogForm aDialogFormGUI = new DialogForm();
if (aDialogFormGUI.ShowDialog()== DialogResult.OK)
{
ThirdForm aThirdFormGUI = new ThirdForm();
aThirdFormGUI.MdiParent = this;
aThirdFormGUI.Show();
}
}
On the Dialog form in the Close event or Click;
DialogResult = DialogResult.OK;
Hope this helps.
|
|
|
|
|
yes.. it worked.. than you very much
can i ask one more question please
how can i run one instance of MDIChild so that if the user invoked the same option again it will not open a new MDIChild.. t should just bring the already openned MDIChild to front..
|
|
|
|
|
Don't know if this is the best way but...
In your MDI Main create a method which passes a temporary Form as a parameter then iterate through all open forms to return the index of the form:
int formIndex = -1;
int i = 0;
foreach (Form cf in this.MDIChildren)
{
// compare the Form you passed with all open Forms
if (passedForm.GetType() == cf.GetType())
{
formIndex = i;
}
i++;
}
Replace the code in the if statement of the dialogresult to:
ThirdForm tempForm = new ThirdForm();
int frmIndex = IndexOfForm(tempForm);
tempForm.Dispose();
// The form is not open
if(frmIndex == -1)
{
ThirdForm ThirdFormGUI = new ThirdForm();
ThirdFormGUI.MdiParent = this;
ThirdFormGUI.Show();
}
// The form is already open
else
{
this.MdiChildren[frmIndex].BringToFront();
}
|
|
|
|
|
NNTP is a thing of the past...its kina dead and people who use forums a lot have a hard time opening the browser and navigating to their thread and stuff. So i thought i'd make a forums to NNTP covertor...by using screen scraping to rip data off the webpages and convert them in the NNTP Usenet msgs form. IS it even remotely possible in C#?
|
|
|
|
|
Possible? Yes. But not practical at all. You'd have to write code to interpret each individual site. And if the site changes their web page, you're re-writing your code.
I thought this is what RSS was for...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
i get yor point dave but the problem with RSS lies in the fact that i can read the post but i can reply to them or post new ones. It's kind of a one way system.
|
|
|
|
|
I agree Daves remarks about the difficulty of generating NNTP data from a webpage. The only practical IMO way to do so would be to work from the backend, the easiest way would probably be to use NNTP as the message store and then build the webversion as an NNTP gateway.
Despite it's age, for high volume sites a good NNTP client is far superior to a webUI. Some of the best ones can approach parity, but are much more dependent on having a high speed, always on, connection which not everyone does.
|
|
|
|
|
Hi all,
I am using the word.application - class. From where do I get the windows handle HWnd or the processID of
the started application ?
Thanks for your help
Frank
|
|
|
|
|
Hi. I think this part of code help you
public void OnStartupComplete(ref System.Array custom)
{
Word wApp= (Word.Application)applicationObject;
}
So use wApp to get all data, you need
Igor.
|
|
|
|
|
Option Explicit
Public Const GW_HWNDNEXT = 2Private Const WM_CLOSE As Long = &H10
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, _
ByVal wCmd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, lpdwprocessid As Long) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Function ProcIDFromWnd(ByVal hwnd As Long) As Long
Dim idProc As Long
' Get PID for this HWnd
GetWindowThreadProcessId hwnd, idProc
' Return PID
ProcIDFromWnd = idProc
End Function
Function GetWinHandle(hInstance As Long) As Long
Dim tempHwnd As Long
' Grab the first window handle that Windows finds:
tempHwnd = FindWindow(vbNullString, vbNullString)
' Loop until you find a match or there are no more window handles:
Do Until tempHwnd = 0
' Check if no parent for this window
If GetParent(tempHwnd) = 0 Then
' Check for PID match
If hInstance = ProcIDFromWnd(tempHwnd) Then
' Return found handle
GetWinHandle = tempHwnd
' Exit search loop
Exit Do
End If
End If
' Get the next window handle
tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT)
Loop
End Function
Sub Test()
Dim hInst As Long ' Instance handle from Shell function.
Dim hWndApp As Long ' Window handle from GetWinHandle.
' Shell to an app
hInst = Shell("winword.exe")
' Begin search for handle
hWndApp = GetWinHandle(hInst)
If hWndApp <> 0 Then
'Sleep for two seconds, then close it
Sleep 2000
Call PostMessage(hWndApp, WM_CLOSE, 0&, 0& )
End If
End Sub
Live Life King Size
Alomgir Miah
|
|
|
|
|
Hi,
I am trying to insert table in the DataSet in compact frame work.
praveen.N
|
|
|
|
|
This is a C# 2005 Problem:
I have an MDIForm and 5 child forms in my project. what i have to do is, during MDI Form's "MdiChildActivate" event I have to set some value to private a variable in my active child form. But when i write a statement like this : this.ActiveMdiChild.childVariableMode="0";
I get an error-"No defination For childVariableMode found in activemdichild". In vb.net i can do this by:
dim a as object
a=me.ActiveMdiChild
a.childVariableMode="0"
But i C# if i do same as VB.NET i get the same error, please solve my problem.I am in very hurry, my whole project is depended on this.
Thanks in Advance.
Sheel
Sheel Gohe
|
|
|
|
|
I am using MySqlConnector for .NET (version 1.0.4), I am using the following code for dataAdapter's update command:
this.codeListAdapter = new MySqlDataAdapter(
"SELECT * FROM CodeList", this.myConnection);
MySqlCommand codeListUpdateCmd = new MySqlCommand(
"UPDATE CodeList SET ProviderID=?ProviderID WHERE DestCode='?DestCode'", myConnection);
codeListUpdateCmd.Parameters.Add("?DestCode", MySqlDbType.VarChar, 10, "DestCode");
codeListUpdateCmd.Parameters.Add("?ProviderID", MySqlDbType.Int16,
0, "ProviderID");
codeListAdapter.UpdateCommand = codeListUpdateCmd;
codeList = new DataTable("CodeList");
this.codeListAdapter.Fill(codeList);
and then I am using the following code, (after changing some rows of 'codeList' ofcourse):
codeListAdapter.Update(codeList);
codeList.AcceptChanges();
but it throws the Exception mentioned above, what might be the problem?
The structure of the 'CodeList' table is like this:
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| DestCode | varchar(10) | | PRI | | |
| Destination | varchar(50) | YES | | NULL | |
| ProviderID | int(11) | | MUL | 0 | |
+-------------+-------------+------+-----+---------+-------+
Thanks in advance...
- A programmer's national anthem; "AAAAAHHHHH!!!!"
|
|
|
|
|
hi all,
I need to change the Color of Tittle Bar in a Windows Form..How can I do it?
thanks in advance..
|
|
|
|
|
hi all,
I need to Color Tool Bar and need to add Blue water mark for buttons when mouse on the Tool Bar Buttons?.
How do I suceed this?.
thanks in advance.
|
|
|
|
|
Hello everybody!
I want to print a document out with A4 paper size programmatically. But I don't know how to define the precise paper size in C#. And also, if I don't use the form's location, how can I locate a particular position of the paper? Could anybody help me with this please!
Thanks in advance
Asura
|
|
|
|
|
This is what I gathered from MSDN in a few minutes:
Choose one of the page sizes from PrinterSettings.PaperSizes collection and put it in the PageSettings.PaperSize property.
---
b { font-weight: normal; }
|
|
|
|
|
Ming Luo wrote:
I want to print a document out with A4 paper size programmatically.
The prefered method is to allow the user to select the paper size since their needs may change after the application is released. To do this, implement a PageSetupDialog. If A4 is the default paper size for the printer, it will already be set in the dialog. If it is not the default size, I believe you could create a PaperSize object, set it to a PaperKind of A4 in PageSettings before printing (or showing the PageSetupDialog). Check the MSDN documentation on PageSettings[^] and PaperKind Enumeration[^].
To implement PageSetupDialog, you can use this code snip from the MSDN article[^] on PageSetupDialog Class in a print button handler. (Note this code assumes a ListBox named ListBox1 that will display the settings (used to indicate how to get the values after the user clicks OK in the dialog) and a PageSetupDialog named PageSetupDialog1.
PageSetupDialog1.PageSettings = <br />
new System.Drawing.Printing.PageSettings();<br />
<br />
PageSetupDialog1.PrinterSettings = <br />
new System.Drawing.Printing.PrinterSettings();<br />
<br />
PageSetupDialog1.ShowNetwork = false;<br />
<br />
DialogResult result = PageSetupDialog1.ShowDialog();<br />
<br />
if ( result == DialogResult.OK)<br />
{<br />
object[] results = new object[]{ <br />
PageSetupDialog1.PageSettings.Margins, <br />
PageSetupDialog1.PageSettings.PaperSize, <br />
PageSetupDialog1.PageSettings.Landscape, <br />
PageSetupDialog1.PrinterSettings.PrinterName, <br />
PageSetupDialog1.PrinterSettings.PrintRange};<br />
ListBox1.Items.AddRange(results);<br />
}
If this doesn't work for you or give you enough clues, post back and let us know.
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
Thanks for your code. But I think what I need is to define the paper size programmatically before the page dialog. Because there is a form need to be filled. For example, if give me a check, I need to fill in the address and customer name information in it, so I need to define the precise position of the address row and customer row in the check, then I put the check into the printer, it will print it. Just like the teller does. Actually it's not a check, what I am doing is a invoice which is A4 size. So another problem is that how can I define the location of the field I need to fill in my program??? Any idea please ?
Thanks very much
Asura
|
|
|
|
|
Ming Luo wrote:
how can I define the location of the field
There are many options. Try this CP article on DaReport PrintDocument[^] to see one approach at positioning objects (including text) on a printed document such as a check. It is not the most straight-forward approach but it is clever and extensible.
Marshall
If you continue to do the same things you always did, don't be surprised if you get the same results you always got.
|
|
|
|
|
Check Out This Code:
PageSetupDialog psd= new PageSetupDialog();
psd.PageSettings.PaperSize = psd.PrinterSettings.PaperSizes[ 4 ]; // 4 denotes the paper index you pass different index and check the Paper size. On my printer paper sizes A4 exits on 4 index.
Try this then tell me.
Muhammad Waqas Butt
waqasb4all@yahoo.com:
Muhamad Waqas Butt
waqasb4all@yahoo.com
|
|
|
|
|
Hello gurus,
I'd like to know how to detect which child has been activated in an MDI?
The MdiChildActivate does not show me which child window has been activated, or maybe there is a cast to do somewhere in the code handler...
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
Although I must admit that I didn't work with MDI much, I'd expect the sender parameter to be the MdiChild that's being activated.
Did you check this?
Regards,
mav
|
|
|
|