saving data with my .exe
I have some data that I want to save inside my .exe instead of
delivering it as separate files. When I was using MFC, I would create a
custom resource in my .RC file, then use FindResource and LoadResource.
What is the equivolent in .NET, or is there another way to achieve my
goal?
I created a custom resource in my app.rc file, just like I would have
in MFC, but I have no idea how to do anything with it. What is the call
to get that resource in a variable I can see?
In other words, I'd like the equivolent of this routine:
CString PutResourceInString(HINSTANCE hInstance, const TCHAR*
szSection, UINT uiResource)
{
HRSRC hFound =
::FindResource(hInstance,MAKEINTRESOURCE(uiResource),TEXT(szSection));
HGLOBAL hRes = ::LoadResource(hInstance, hFound);
int iSize = ::SizeofResource(hInstance, hFound);
LPVOID lpBuff = ::LockResource(hRes);
CString csRet;
char* psz = csRet.GetBuffer(iSize+1);
memcpy(psz, lpBuff, iSize);
psz[iSize] = '\0';
csRet.ReleaseBuffer();
::UnlockResource(hRes);
::FreeResource(hRes);
csRet.Replace("\r\n", "\n");
return csRet;
}
Thanks! Tag: Hide Tabpage Tag: 108264
Slow redraw of controls when scrolling
Hi all!
I am running VS2005/,NET 2.0, and experience really slow performance on
the refresh rate of GUI when scrolling my forms.
To debug, I just created a clean UserControl and added about 50 empty
textboxes to it, no databinding, and set the AutoScroll property to
true.
When scrolling, the screen is updated really slow, the textboxes are
drawn partially, and blurr. CPU usage is 95-100%.
Does anybode know why this happens?
Best regards
Anders Tag: Hide Tabpage Tag: 108260
ADV: / SPAM: Job Posting Assistance
All,
Sorry for this "off topic" post but you all are always so helpful.
We are a small company headquartered in Dallas / Fort Worth with 5 servers,
2 sites, 25 workstations and a couple remote users. We are outgrowing my
ability to keep up and the ability to keep up development on small projects.
We are looking to hire a cross job type person. Here's what I am after...
Someone that can focus on web and database application development. There
would also be a need to for the general network maintenance of servers and
user issues and questions, along with input the IT infrastructure of today
and tomorrow.
Where is the best place to begin a search for qualified candidates in the
Dallas / Fort Worth, Texas area?
Thanks,
Brian Tag: Hide Tabpage Tag: 108255
Data grid hierarchal navigation
I have hierarchal data grid that has parent and child tables linked via
data relation. I would want the child row to be displayed with out
having to click on the relation link the windows forms grid within the
same grid. How can I achieve this?
Thanks Tag: Hide Tabpage Tag: 108254
Launch IE with a complex string
Hi
I am working on integrating some help modules and i need to launch the
browser with a url like
X:/WebHelp_WithTOC/index.htm#mergedProjects/ProductA/ProductA_Form1.htm
while i can have a form and a webBrwoser control in it and pass this as
a URl, i want to specifially launch IE with this page.
The standard System.Diagnostics.Process.Start(String filename) does not
work in this case. The error is 'the specified file could not be
found'. In this function it considers the entire string to be proper
path for a file cos the string starts with X:.
How can i launch this url in a new instance of IE?
Thanks Tag: Hide Tabpage Tag: 108252
Textbox copy and paste problem
I have create a very simple windows form application. I am using textbox
control, but I am unable to copy and paste text into the textbox by using
keyboard hot key.
Anyone come across this problem before?
Thanks Tag: Hide Tabpage Tag: 108237
Transparent ContextMenuStrip with non-transparent text
Hi,
I am trying to implement a context menu that is 50% transparent. Setting
the opacity to 0.5 works but unfortunately the texts are also displayed
with transparency which makes them very hard to read.
Now I would like to draw the menu background with transparency but the text
without.
I have tried various approaches without success:
- Implement a ToolstripRenderer: Draws a gray background despite overriding
all overridable methods
- Handle Paint event of each menu item: Text gets drawn with transparency
Does anybody have an idea how to approach this?
Thanks in advance,
Hans Tag: Hide Tabpage Tag: 108234
Bug or bad design in System.Windows.Form.Form
Hi
While developing a Windows forms application I encountered what I
consider to be a bug or a design flaw:
Consider to have 3 Forms namely A B and C. B is owned by A and C is
owned by B. If we close A, all three forms should close which is exactly
the design described in the class library reference on msdn.
However, if the windows run in NON modal mode (i.e. not showed using
ShowDialog(IWin32Window), closing A does call the OnFormClosing on A and
on B but NOT on C. C gets closed without a way to check for unsaved
data, because the FormClosing event doesn't get raised.
If window B and C run in Modal mode (ShowDialog(IWin32Window)), C raises
the FormClosingEvent (from within the OnFormClosing Method), but setting
e.cancle = false will NOT prevent the window from closing, and even
worse, the OnFormClosing method will run AFTER the window has already
been disposed.
Possible Reason:
The invaluable resource .NET Reflector gave me some insight to the
Implementation of the System.Windows.Forms.Form class. When a window
closes, it calls OnFormClosing on all of its MdiChildren and Owned
Windows. If e.cancle does not evaluate to false after these calls, the
form gets Disposed. Dispose(bool disposing) calls Dispose on all owned
forms, and thus it works recursively. But OnFormClosing does NOT. So
when I call A.Close() it "asks" B to close, and if B does not set
e.cancle, A disposes itself which in turn disposes B and C. So C gets
Disposed without a prior call to OnFormClosing and no event rising.
Shouldn't the (private) WMClose method in System.Windows.Forms.Form call
some RECURSIVE method to check recursively for all owner relationships
if the owned forms (in all levels of the owner relationship) can close?
Possible workaround: (NOT tested yet)
override the OnFormClosing method that it calls OnFormClosing for all
owned forms recursively. This however will cause the OnFormClosing
method to be called twice for all owned forms that are directly owned by
the "root" form, because WMClose calls OnFormClosing on all its directly
owned forms, and later calls this.OnFormClosing.
The loop which calls OnFormClosing for all owned forms shouldn't be in
WMClose but rather in OnFormClosing itself, thus be recursive.
For MdiWindows this problem does not exist, because MdiCild Relations
can only exist in one level, so for MdiChildren this problem does not
exist. But when one closes the MdiParent of an MdiChild which owns some
window X, OnFormClosing and the FormClosing Event will NOT be called for X.
Has anyone ever encountered problems with this behavior as I did? And
how did you solve the problem?
I would consider this behavior either a bug or a design flaw!
Regards
Stephan Tag: Hide Tabpage Tag: 108232
ControlDesigner OnMouseDragMove only called once?
I am playing with overriding the ControlDesigner OnMouseDragMove. But for
some reason it only appears to get called when a control just begins its
drag. I was anticipating it to be called for every movement of the mouse
during the drag. Am I missing something so that this method is only called
once? Is there another method I should be using that will be called for
each movement of the mouse? Tag: Hide Tabpage Tag: 108231
notification windows a la Outlook
Hi all,
I've been recently struggling to get to the bottom of this, but can't
find the proper way to do this. I have a notification window, which may
appear on screen when certain events are received. Currently the notes
are created and displayed on the main form's gui thread. It works ok,
until you go into 'modal' mode. That is, if there are a modal form and
the note simultaneously on the screen, I cannot click on the notify
window.
There are two scenarios here: first the note pops up, then a modal
window is opened; or the other way around: you receive the note while
the modal window is on top. In both cases, I can't access the note.
I looked at Outlook, how it behaves, and you can access the note (of
course, trying to 'open' the email results in a warning message,
stating it can't do that while modal windows are opened). I believe
Outlook is using a different thread for the notes. I tried to do this,
but it's not that easy. Notes must be _created_ (and displayed) on the
'notification thread'.
Bottom line: I want to be able to create and display the notes from the
gui thread, on the notes' thread (ideally I want only one thread for
all notes, not one thread for each note).
Any ideas are welcome.
Thanks in advance,
Cosmin. Tag: Hide Tabpage Tag: 108227
VB WinForms Application doesn't inherit from WindowsFormsApplicationBase
Hi there,
Just out of curiosity....
Looking into Application.designer.vb as part of MyProject i see
Partial Friend Class MyApplication
<Global.System.Diagnostics.DebuggerStepThroughAttribute()> _
Public Sub New()
MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows)
..
End Sub
..
End Class
how come this class class doesn't or should i say "where does this class"
inherit from WindowsFormsApplicationBase? I can see thats its partial and
that its calling mybase.new but wheres the rest?
Ive looked into the directory using windows explorer but still cant find it.
Is this part of the visual studio/ vb compiler hoo doo voodoo?
thanks
richard Tag: Hide Tabpage Tag: 108215
Print Dialog
I need to programmically close a PrintDialog form after it is displayed with
the "ShowDialog" method in case the user does not dismiss it himself. My app
needs to have it time out. How can this be done ? Tag: Hide Tabpage Tag: 108211
SystemParametersInfo call hanging.
Due to the nature of our application, it is necessary to set a system
setting that increases the size of the scrollbars when the application
is the "active" one. When it is not, the system setting is reverted so
that the scrollbars appear in their normal size.
To achieve this, I am overriding the WndProc method and checking if the
message received is WM_ACTIVATEAPP, (this is the message received when
the application gets focus). Upon receipt, I make a call a call to the
user32.dll call SystemParametersInfo to make a change to the scrollbar
size.
This seems to work just fine, but when my application receives a
SystemEvent.PowerModeChanged or SystemEvent.DisplaySettings event, my
call to SystemParametersInfo (called via the WndProc override) seems to
hang... and I can't figure out why.
Does anyone have any ideas on why the call to SystemParametersInfo
would hang? It requires the user to kill the application.
Thanks, Tag: Hide Tabpage Tag: 108210
SystemParametersInfo call hanging.
Due to the nature of our application, it is necessary to set a system
setting that increases the size of the scrollbars when the application
is the "active" one. When it is not, the system setting is reverted so
that the scrollbars appear in their normal size.
To achieve this, I am overriding the WndProc method and checking if the
message received is WM_ACTIVATEAPP, (this is the message received when
the application gets focus). Upon receipt, I make a call a call to the
user32.dll call SystemParametersInfo to make a change to the scrollbar
size.
This seems to work just fine, but when my application receives a
SystemEvent.PowerModeChanged or SystemEvent.DisplaySettings event, my
call to SystemParametersInfo (called via the WndProc override) seems to
hang... and I can't figure out why.
Does anyone have any ideas on why the call to SystemParametersInfo
would hang? It requires the user to kill the application.
Thanks, Tag: Hide Tabpage Tag: 108209
ANN: TayLayout Release 00.00.15 for IronPython
TayLayout Release 00.00.15 for IronPython
http://code.google.com/p/taylayout/downloads/list
New This Release
* Wordsearch generator sample (80% functional)
* More controls specially supported (listbox, webbrowser)
* More compound controls
* Controls can now be right-aligned
* Plenty of bug fixes
TayLayout is a more sophisticated version of the flow layout - you can
add controls to a panel or form and it takes care of positioning them.
Controls are added in a Left to Right order until you specify that a
new line is required.
More info available at
http://docs.google.com/View?docid=dd59dk39_2jh3xf9
Thanks,
Davy Mitchell Tag: Hide Tabpage Tag: 108205
Find the day of the Week
I am currently writing a program in Visual Basic .NET and need to be able to
find the day of the week when given the date (Ex. 1/20/07). Once the
function is given the date it will the deliver the day such as Sunday,
Monday, Tuesday and so on. Thank you very much.
b89 Tag: Hide Tabpage Tag: 108202
Windows CBT Hooks (Help!)
I hope you can answer a question. I am writing a poker utility that
tracks what windows are open and displays information about opponents
that are still playing and their previous history that is stored in a
game DB. It is a very cool project with Pattern Recognition (Pixel
Screen SCraping to OCR) and pretty advanced calculations. I
just started writing my first prototype in C# and discovered that I
could not set a System Wide CBT hook.
.Net will not allow hooks CBT hooks to be set globally, period! Works
for mouse and keyboard, but not CBT.
I need to trap when a window is created, destroyed, gotfocus, or
resized. I do not want to cancel or redirect those messages. I just
need to get new rect information about the window.
I have discovered ways of doing it in either VB6 or C++. I am not sure
which is the best strategy to pursue. I do not code in either
language. Can I have this hook in VB or C++ and then call my C#
function? Anone have any suggestions for interacting in between
managed and unmanaged code when the unmanaged code needs to trigger a
C# method?
Thanks,
Andy Tag: Hide Tabpage Tag: 108201
ImageList performance problem
Hi all,
I'm experiencing performance problems when adding a large set of
bitmaps to an ImageList. The bitmaps are 55x55 pixels in size, which
matches the ImageList's ImageSize property. Adding approx. 5000 bitmaps
takes about 1,5 minutes. The bitmaps are generated from scratch,
resized and other things much faster than that (in just a few seconds)
so why should adding them to an imagelist be so slow?
The imagelist is also the source for a ListView, which displays the
results. I've tried adding the bitmaps to the ImageList via Add(),
AddRange() and using the async. virtual mode. The latter sounded
promising, but didn't help.
Any ideas, hints?
Cheers,
Johan Sj=F6str=F6m
MSc, MCAD, MCTS, MCITP Tag: Hide Tabpage Tag: 108199
Where are the 'most often used program' shortcuts stored?
Hi,
I'm talking about the ones that are displayed in the XP Start menu?
Does anyone know
where they are/how to get a list of them.
Cheers,
James Randle. Tag: Hide Tabpage Tag: 108197
Reason for Application.ThreadExit
Hi,
We have the strange problem that sometime in our application
Application.ThreadExit is raised and out application shutting down.
We do not see any previous exceptions before this event fires.
Moreover the Application.ThreadException event is not fired at all, so
we have not unhandled exceptions that occurs.
We are working with SQL-2005 and with some unmanaged code too.
What can be the reason for such behaviour ? And how can we catch such
error ?
Thanks,
Pavel Tag: Hide Tabpage Tag: 108195
Render window to video port?
Is it possible to redirect the rendering of a windows form to the video
port/overlay device of a video card? In my situation I must present the
contents of a window on an hdtv and I can't use a desktop clone trick
because there's going to be another application running that cannot
show up on the tv. Any ideas? Tag: Hide Tabpage Tag: 108188
freeware .NET graph library needed
Hi!
I need such library to make UML modeler with which i'd be able to make
UML schemas(primarily for designing software projects).What i'm trying
to achieve is to make something like any other UML drawing tool.
I've found some commercial ones(yFiles.NET, Essential Diagram)and
freeware Netron graph library(but it doesn't contain all UML elements).
Thanks! Tag: Hide Tabpage Tag: 108175
vs2003 to vs2005
Hi
I have a vb.net 2003 database winform app which uses non-bound controls and
the associated plumbing is done in code. If I move it to vs 2005 would it
work without any change?
Thanks
Regards Tag: Hide Tabpage Tag: 108169
Moving the MdiClient area
I programmatically moved the MdiClient of my MDI form to be nested
inside a Panel so I can control the layout better. I also removed the
3D border on the MdiClient using Interop.
When trying to open MDI child forms, I first received an error about
the parent not being an MDI container. I suspected this was because I
moved the MdiClient, so I set IsMdiContainer back to true after the
move. I no longer get the error, but now the MDI children don't
display at all.
I'm assuming I need to hook the MdiClient back up to the parent form
somehow. How do I do this while keeping the MdiClient nested in a
Panel?
TIA
Jared Tag: Hide Tabpage Tag: 108168
VS 2005 SP1
Hi
I am almost finished with a vs 2005 (pre sp1) project which I need to
deliver in the next couple of days. I am wondering if I should deliver
project with sp1. Is it safe to install sp1 at this late stage?
Thanks
Regards Tag: Hide Tabpage Tag: 108166
"UpdateEvent"
I'm looking for some kind of form level event that I can hook/add/use
to tell me when ever some input control has changed its state. As a
hack currently I set KeyPreview to true and hooked the KeyPress event.
This works great for text boxes etc, but if a user uses the mouse to
select someting in a listbox it doesnt catch it of course.
The idea is something like this, in the even I want to check the state
of the inputs and enable disable for example the Save button. Delphi
had a neat way to do this with actionlist and I know there are free and
3P action lists for .NET, but this is an existing WinForms app and I
cant redo it. I just need a basic event I can hook to properly
enable/disable controls. The other "hack" option is a timer, but thats
pretty ugly too.
I've also considered hooking into the windows message pipe and ignoring
obvious ones like WM_Paint etc, but again I'd like to avoid this and
find something else. Anyone have any suggestions?
--
Chad Z. Hower
Microsoft Regional Director
"Programming is an art form that fights back"
http://www.KudzuWorld.com/
Need a professional technical speaker at your event?
http://www.woo-hoo.net Tag: Hide Tabpage Tag: 108161
Flashing scrollbar on MDI child window after cursor key hit!
My application has a main form with its "IsMdiContainer" set to 'true'.
I create a form to serve as a child form, setting its "MdiParent" to the
main form before calling its "Show()" method. The "AutoScroll" property is
set to 'false'.
My child form class has two scroll bars which I added manually; an
HScrollBar and a VScrollBar. Each of these scroll bars has its "TabStop"
property set to 'false'. (As mentioned above, the "AutoScroll" property of
the child form class is set to 'false'; I do not want to use the form's
automatic scroll bars.)
Any instance of the child form properly has its OnKeyDown() handler
triggered when the child form has focus and regular keys are pressed.
All works great -- until I press a cursor key (i.e., up, down, left, right).
When I press a cursor key, one of the scroll bars starts to scroll, and
starts to
flash! When I release the cursor key, the scroll bar continues to flash,
and no
other key events are received by the child window.
Wait... I just solved my own problem!
Override OnPreviewKeyDown(), and then disable each scrollbar (set its
"Enabled" property to 'false'), and call Invalidate(false) to put a repaint
message in to the queue for the form. When the scrollbars are disabled, this
is evidently enough to prevent the cursor key from finding a scrollbar and
locking to it, starting the flashing, and capturing the input. Upon repaint
we can set the Enabled property of the scrollbars back to 'true' if
appropriate.
Whew! I thought I was going to have to implement my own "MDI" logic instead
of using the "IsMdiContainer" feature. Wow, the worst part about Windows
Forms is the crazy logic concerning how cursor key events, mouse wheel
events, focus, and other things are handled... What next?!
Anyhow, I am sharing my discovery for the benefit of others.
--- Colin Tag: Hide Tabpage Tag: 108136
How to iterate over a combobox's items?
Say cbRoadwayType is my combobox:
for (int i = 0; i < cbRoadwayType.Items.Count; i++)
{
cbRoadwayType.SelectedIndex = i;
int val = (int)cbRoadwayType.SelectedItem // INVALID EXCEPTION cast
if (val != FILTER_ALL && val != FILTER_NOT_SET)
{
roadwayList.Add(val);
}
}
But, I get an invalid exception cast. How do I just get the value of the
combobox item, based on an index?! Tag: Hide Tabpage Tag: 108132
Packaging registry file only, please
Hi! Is there a way to package registry file only? I can not seem to find the
way using VS 2003 & Package and Deploy Wizard.
In a nutshell, I need to merge a .reg file to create some keys + values.
I need to create an .msi package as our clients do not accept anything else.
I can not really write a program that does it programmatically and then
package it.
Any help is greatly appreciated.
Many thanks in advance, Tag: Hide Tabpage Tag: 108131
Multiline TextBox with Autocomplete?
I have noticed that Autocomplete stops working when you set a TextBox to
Multiline. Is this the designed behavior? Is there any way to make it work,
other than developing your own custom control? I would also like to see a
behavior where the list of suggested items resets after each space, so in
other words you could use Autocomplete multiple times in the same TextBox.
Do I have to start developing my own control for this?
--
Paul Fountain, Software Engineer
InsureMe Tag: Hide Tabpage Tag: 108117
Is .NET no good for some things?
This is a multi-part message in MIME format.
------=_NextPart_000_001E_01C7362A.C4679EC0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
It used to be simple in Basic to "open" a printer (like LPT1), then =
"write" ASCII characters to it. Alternatively, one could create a =
text-file, then a simple DOS copy operation could copy the text file to =
a printer using shell. There is no documentation to indicate how this =
might still be accomplished=20
Does anybody know if one can still "copy" a file to a windows printer =
i.e. use shell to dump a text file to a device (e.g. \\main\HP Laser =
which might be a printer attached to one of the nodes of the network or =
perhaps to 192.168.1.20 which might be the IP address for a network =
printer)? I believe copy can still be done if one maps a device to LPT1 =
or something. However, I'm not sure about how to do this using the =
network name or the IP address of the printer if it is not connected as =
a shared resource of a PC
Thanks and have a great day!
Bill Angus, MA
http://www.psychtest.com
------=_NextPart_000_001E_01C7362A.C4679EC0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1586" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>It used to be simple in Basic to "open" =
a printer=20
(like LPT1), then "write" ASCII characters to it. Alternatively, one =
could=20
create a text-file, then a simple DOS copy operation =
could copy=20
the text file to a printer using shell. There is no documentation to =
indicate=20
how this might still be accomplished </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Does anybody know if one can still =
"copy" a=20
file to a windows printer i.e. use shell to dump a text file to a=20
device (e.g. <A href=3D"file://\\main\HP Laser">\\main\HP =
Laser</A> =20
which might be a printer attached to one of the nodes of the network or =
perhaps=20
to 192.168.1.20 which might be the IP address for a network printer)? I =
believe=20
copy can still be done if one maps a device to LPT1 or something. =
However, I'm=20
not sure about how to do this using the network name or the IP address =
of the=20
printer if it is not connected as a shared resource of a =
PC</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>Thanks and have a great day!</DIV>
<DIV> </DIV>
<DIV>Bill Angus, MA<BR><A=20
href=3D"http://www.psychtest.com">http://www.psychtest.com</A></FONT></DI=
V></BODY></HTML>
------=_NextPart_000_001E_01C7362A.C4679EC0-- Tag: Hide Tabpage Tag: 108114
Added integrated help to my application
Hi,
I'd like to add help functionality to my application. I like how the
integrated help displays in Visual Studio, and would like to simulate
this in my own application.
What technologies / components would I need to look at to get this
working? I would want the viewer on its own form, which would be set
as an MDI child.
Thanks
Andy Tag: Hide Tabpage Tag: 108112
How do I stop FlashWindowEx when me.handle gets focus?
Hi....
I'm using FlashWindowEx to flash the taskbar and titlebar when my processes
are done.
I set the number of flashes to 5. But when the user returns to the window
the flashing
continues until all 5 flashes complete.
How do you stop the flashing once the user returns to the app.? (Code
Below)
Thanks for any help,
Marc Miller
Public Structure FLASHWINFO
Public cbSize As Int32
Public hwnd As IntPtr
Public dwFlags As Int32
Public uCount As Int32
Public dwTimeout As Int32
End Structure
Private Declare Function FlashWindowEx Lib "user32.dll" (ByRef pfwi As
FLASHWINFO) As Int32
Private Const FLASHW_CAPTION As Int32 = &H1
Private Const FLASHW_TRAY As Int32 = &H2
Private Const FLASHW_ALL As Int32 = (FLASHW_CAPTION Or FLASHW_TRAY)
Public Sub FlashNow(ByVal sender As System.Object, ByVal e As
System.EventArgs, ByVal iTimes As Integer)
Dim flash As New FLASHWINFO
flash.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(flash)
'/// size of structure in bytes
flash.hwnd = Me.Handle '/// Handle to the window to be flashed
flash.dwFlags = FLASHW_ALL '/// to flash both the caption bar + the
tray
flash.uCount = iTimes '/// the number of flashes
flash.dwTimeout = 1000 '/// speed of flashes in MilliSeconds ( can
be left out )
'/// flash the window you have specified the handle for...
FlashWindowEx(flash)
End Sub Tag: Hide Tabpage Tag: 108101
access another forms controls & properties at runtime
how can you access a control on a form from another form at runtime. For
example to set the datasource and datamember properties of a forms binding
source from a different form?
I am trying to do something like:
form test = new form();
test.show();
test.bindingsource.DataSource = bla bla; Tag: Hide Tabpage Tag: 108091
Using variable as form field name
Hi
I have two fields field1 and field2 on my form. Is there a way that the
field names can be accessed via variable so that choice of the actual field
to access is decided at runtime?
Thanks
Regards Tag: Hide Tabpage Tag: 108090
Is this normal
Hi there,
Is it normal for form-based events to fire in "InitializeComponent()". I've
got a "DataGridView" on a form and I set its "CellValueChanged" event using
the forms designer. Ok, VS initializes my event in "InitializeComponent()".
However, "InitializeComponent()" later calls
"ComponentResourceManager.ApplyResources()" which (to my great surprise)
fires my event (which my handler then chokes on since it thinks the window
is already running). Looking at the call stack, the event was fired while
initializing the header text on one of my "DataGridView" columns (from the
resource file). I'm not sure if this particular event should even apply in
this situation but in any case, the form hasn't even been created yet. Is it
therefore normal for some form-based events to be fired while the
constructor is still running. If so then it's potentially dangerous to
define events using the forms designer so we should presumably add them
ourselves in "OnLoad()" typically (or otherwise design all handlers to check
that the window has actually been created which is ugly IMO). Can anyone
elaborate on this situation. Thanks. Tag: Hide Tabpage Tag: 108085
DataGridViewComboBox selectively hide arrow
I have a column on my DataGridView that is of the type
DataGridViewComboBoxColumn. On some of my rows, I want to keep the user
from changing the value in that field.
What I'm doing now is, as soon as I populate my rows, I run through
each row something like this:
private: System::Windows::Forms::DataGridView^ Fields;
...
#define COMBO_COL 3
for (int i = 0; i < Fields->RowCount; ++i)
{
if (it shouldn't be changed)
{
Fields->Rows[i]->Cells[COMBO_COL]->ReadOnly = true;
}
}
That works, but it both looks ugly and doesn't give the user a clue
about why the combo box's arrow doesn't do anything.
Ideally, what I'd like to do is hide the arrow altogether for those
rows. Does anyone have any ideas about how to do that?
One thought is that I could change the cell type on the fly to a
regular edit cell. I'm not sure how to do that, or if that would just
confuse the control altogether. Tag: Hide Tabpage Tag: 108077
Drag-n-Drop to Folder or Desktop
I have a form that displays a list of bitmaps. I have read the MSDN docs
regarding drag-n-drop operations, and have reviewed some examples online on
how to do this, but the examples I have seen thus far only show how to
create an internet shortcut file.
When the user drags an image from the form to the desktop, I would like to
either save the image using a default filename (if possible) or show the
Save As dialog so the user can enter a name for the file themselves. So,
the form with my images (which are in-memory bitmaps and are not stored on
the file system) needs to be able to have the images dragged from the
ListView control (which are ListViewItem's of course) and dropped onto a
specified folder or the desktop (actual folder or desktop, not part of my
app)...
Thanks,
Mythran Tag: Hide Tabpage Tag: 108063
Help. Getting exception when I rebind grid to another dataset and change column names
Hi,
I am using a datagrid and two dataset with different data. Both views
of the grid contains 5 columns. I toggle between two different views of
the grid which display different types of data. When I toggle, I change
the last 3 columns to different name and bind a different dataset. When
I startup the application, the first dataset when I click on any empty
cells, it works find. However, when I switch for the first time to the
alternative dataset and change the name, it will throw an exception
Index was out of range. Must be non-negative and less than th esize of
the collection.
Parameter name: index
When I keep the column names the same between the two grid views, it
works fine. However, I need to change the column names to indentify the
column type of data.
Any help is appreciated. Tag: Hide Tabpage Tag: 108062
Generating a modal form from a MDI child form
I am trying to display a simple modal form from a button on a displayed MDI
child form toolstrip.
Does anyone have some simple sample code example to send me.
Will be much appreciated. Tag: Hide Tabpage Tag: 108058
hiding public methods in the DropdownList.
hi guys!
again with some interesting Question.
i've some public methods in class. i dont want to show this methods in
the dropdown list while you are typing the code in .net IDE (it long
story that why i dont need those methods in the list).
i guess there are some arrtibutes those can prevent showing method in
the popuped dropdown list but as i dont have much idea about this
attributes, i need your expert help on this.
please let me know if you know how can i do this or may be some other
resource that can help me to find out the way of doing.
thanks,
Lucky Tag: Hide Tabpage Tag: 108042
WebBrowser in UserControl in IE HTML
Hi,
I built a Windows Control Library that includes the WebBrowser
component. It runs fine in Windows Apps or the TestContainer. When I
embed it into a web Page as <object> it displays only the outline. When
I delete the WebBrowser from the UserControl it runs fine. All IE
security settings are set to minimum.
Do you know about security restrictions related to "component in
component in IE"?
thanks
marc Tag: Hide Tabpage Tag: 108041
TreeView & WM_PAINT
I'm curious, given the below code, where does .NET perform the drawing
of the treeview? I'm especailly interested in how a TreeNode is painted
on the screen with a checkbox in front of it.
And yes, I'm fully aware of the TreeViewDrawMode.OwnerDrawText and
base.SetStyle(ControlStyles.UserPaint, true); options.
class TreeViewE : System.Windows.Forms.TreeView
{
public TreeViewE()
{
this.DrawMode = TreeViewDrawMode.Normal;
}
}
By using .NET Reflector on System.Windows.Forms.dll I have debugged the
issue at bit.
It seems the TreeView::WndProc does not handle WM_PAINT message and
send it to the base class.
The Control::WndProc forwards the WM_PAINT message to WmPaint.
Here is where I get a bit lost. The method is pasted in below but its
difficult to follow it, especially with "Native" methods being called.
I'm assuming at some stage the Graphics object needs to be used to draw
text, checkbox etc.
private void WmPaint(ref Message m)
{
if (this.DoubleBuffered ||
(this.GetStyle(ControlStyles.AllPaintingInWmPaint) &&
this.DoubleBufferingEnabled))
{
IntPtr ptr1;
Rectangle rectangle1;
NativeMethods.PAINTSTRUCT paintstruct1 = new
NativeMethods.PAINTSTRUCT();
bool flag2 = false;
if (m.WParam == IntPtr.Zero)
{
ptr1 = UnsafeNativeMethods.BeginPaint(new HandleRef(this,
this.Handle), out paintstruct1);
rectangle1 = new Rectangle(paintstruct1.rcPaint_left,
paintstruct1.rcPaint_top, paintstruct1.rcPaint_right -
paintstruct1.rcPaint_left, paintstruct1.rcPaint_bottom -
paintstruct1.rcPaint_top);
flag2 = true;
}
else
{
ptr1 = m.WParam;
rectangle1 = this.ClientRectangle;
}
IntPtr ptr2 = Control.SetUpPalette(ptr1, false, false);
try
{
if ((rectangle1.Width > 0) && (rectangle1.Height > 0))
{
Rectangle rectangle2 = this.ClientRectangle;
using (BufferedGraphics graphics1 =
this.BufferContext.Allocate(ptr1, rectangle2))
{
Graphics graphics2 = graphics1.Graphics;
graphics2.SetClip(rectangle1);
GraphicsState state1 = graphics2.Save();
using (PaintEventArgs args1 = new
PaintEventArgs(graphics2, rectangle1))
{
this.PaintWithErrorHandling(args1, 1,
false);
graphics2.Restore(state1);
this.PaintWithErrorHandling(args1, 2,
false);
graphics1.Render();
}
}
}
}
finally
{
if (ptr2 != IntPtr.Zero)
{
SafeNativeMethods.SelectPalette(new HandleRef(null,
ptr1), new HandleRef(null, ptr2), 0);
}
}
if (flag2)
{
UnsafeNativeMethods.EndPaint(new HandleRef(this,
this.Handle), ref paintstruct1);
}
}
else
{
if (m.WParam == IntPtr.Zero)
{
NativeMethods.PAINTSTRUCT paintstruct2 = new
NativeMethods.PAINTSTRUCT();
IntPtr ptr3 = this.Handle;
IntPtr ptr4 = UnsafeNativeMethods.BeginPaint(new
HandleRef(this, ptr3), out paintstruct2);
IntPtr ptr5 = Control.SetUpPalette(ptr4, false, false);
try
{
PaintEventArgs args2 = new PaintEventArgs(ptr4, new
Rectangle(paintstruct2.rcPaint_left, paintstruct2.rcPaint_top,
paintstruct2.rcPaint_right - paintstruct2.rcPaint_left,
paintstruct2.rcPaint_bottom - paintstruct2.rcPaint_top));
try
{
if
(this.GetStyle(ControlStyles.AllPaintingInWmPaint))
{
this.PaintWithErrorHandling(args2, 1,
false);
args2.ResetGraphics();
}
this.PaintWithErrorHandling(args2, 2, false);
return;
}
finally
{
args2.Dispose();
if (!this.IsDisposed && this.IsHandleCreated)
{
ptr3 = this.Handle;
}
UnsafeNativeMethods.EndPaint(new
HandleRef(this, ptr3), ref paintstruct2);
}
return;
}
finally
{
if (ptr5 != IntPtr.Zero)
{
SafeNativeMethods.SelectPalette(new
HandleRef(null, ptr4), new HandleRef(null, ptr5), 0);
}
}
}
PaintEventArgs args3 = new PaintEventArgs(m.WParam,
this.ClientRectangle);
this.PaintWithErrorHandling(args3, 2, true);
}
}
Appreciate any input Tag: Hide Tabpage Tag: 108036
Question Regarding Multiple Resource File..
Hello,
I have a product which is customized for multiple vendors for eg:-
cisco,hitachi,sony etc.
When user installs the app on a cisco vendor all the icons,bitmaps, strings
should be cisco and viceversa. What's the best way to achieve this.
I was thinking about the same concept of satellite assembly for multiple
cultures.
So based on the installation it will pick the correct resource file from the
installation folder.
Is this method feasible?, or do we have any other better methods.
Also i will not be putting any resource in the main app.
Dot .net Gurus Please advice me.
Thanks,
Vineeth Tag: Hide Tabpage Tag: 108033
Default icon for custom file using C#
I have been trying to get a solution to this problem for quite sometime
now.
I produce custom files in my Windows Application (binary serialization
of some objects) with some extention, say "file.abc"
Now I want a default icon to be assigned to this file (like in Office,
the Excel/Word/etc. icon is assigned to appropriate extentions); so
that when somebody double clicks on the file, my application is started
with this file as a parameter, which I catch in Main().
Is there any elegant way of doing this in C# - maybe some setting I
have to include when created the Setup for the application, or maybe
some API I have to use in C# when creating this file.
Thanks in advance.
- Maneesh Tag: Hide Tabpage Tag: 108031
Title bar of Windows form is stuck in resize state when x coordinates and top y coordinate of form are negative
Hello,
I think I found a bug in the Windows forms engine related to multiple
monitors and I wonder if anyone saw that too. If yes, any workaround?
Steps to reproduce:
1. connect two monitors to your PC, extend your desktop to both
monitors
2. In the monitor settings dialog, drag monitor 2 so that it is to the
left of monitor 1. This makes x screen coordinates of monitor 2
negative. Also make sure monitor 2 extends above monitor 1, so that top
y coordinate is negative as well. This happens to be my default setup,
I have a larger monitor to the left of my laptop screen.
3. Open a sizeable modal dialog in a dotnet 1.1 Windows forms
application.
4. Click and hold the left mouse button on the title bar of the dialog,
move it to monitor 2.
5. Now release the mouse.
6. Move the mouse over the title bar area, notice what happens.
What I see:
- If the window is on the left screen and its top is above the top
border of monitor 1, mouse cursor is always NW-SE resize cursor over
the title bar unless the dialog is maximized. If the title bar is
partially above the y=0 coordinate, the strange behavior is only
apparent for the part where y is negative.
- it is no longer possible to move the dialog by dragging the title
bar. Attempting to do so resizes the window rather than moving it
- it is not possible to use the [x] button to close the window unless
it is maximized
- normal behavior will only resume after you manage to move the window
back to monitor 1 by resizing it. This will not be possible at all
unless the "show in taskbar" property of the Window is set and maximize
is allowed. Tag: Hide Tabpage Tag: 107997
OS DateTime Format Setting
Is there a way to determine the OS's date/time culture format (e.g.
mm/dd/yyy vs. dd/mm/yyy) setting at run time?
TIA
Brad Tag: Hide Tabpage Tag: 107990
NumericUpDown control crashes
We encounter a bug in winform application in .net 2.0 that
often when we press continually on a NumericUpDown control the
application crash with the following exception :
System.NullReferenceException occurred
Message="Object reference not set to an instance of an object."
Source="System.Windows.Forms"
StackTrace:
at
System.Windows.Forms.UpDownBase.UpDownButtons.TimerHandler(Object
source, EventArgs args)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at
System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm) Tag: Hide Tabpage Tag: 107981
Form's - Border Color
Hi,
How can I change form's border color?
Or is there any method to hide/show form's border at runtime.
Either one will work for me.
Ex: If user wants to keep background green, border also should change to
green color.
Best
% V Tag: Hide Tabpage Tag: 107980
???Dispose dynamic menu items
Hi People
I have a WinForm program. The UI contains a ToolStripDropdownButton,
which is associate a list of menu items of ToolStripMenuItem, created
dynamically. Upon different scenarios of user operations, the
DropdowButton need to clean up all its menuitems, and create new ones.
Here the codes:
////////////////////
Void CreateForEmail()
{
...
button.DropDownItems.Clear();
...
button.DropDownItems.Add("To:", null, HandleOutlookToClick);
button.DropDownItems.Add("CC:", null, HandleOutlookCCClick);
}
Void CreateForPhone()
{
...
button.DropDownItems.Clear();
...
button.DropDownItems.Add("Phone", null, HandlePhoneClick);
}
Void CreateForNone()
{
button.DropDownItems.Clear();
}
////////////////////////
So far so good, just work as I expect.
Later on, I found out that " button.DropDownItems.Clear();" does not
dispose the menu items at all, when I decided to add shortcutkeys to
menu items. The above codes were changed in order to have shortCutKeys:
////////////////////
Void CreateForEmail()
{
...
button.DropDownItems.Clear();
...
button.DropDownItems.Add("To:", null, HandleOutlookToClick)
.ShortcutKeys = Keys.F9;;
button.DropDownItems.Add("CC:", null, HandleOutlookCCClick);
}
Void CreateForPhone()
{
...
button.DropDownItems.Clear();
...
button.DropDownItems.Add("Phone", null, HandlePhoneClick) .ShortcutKeys
= Keys.F9;;
}
Void CreateForNone()
{
button.DropDownItems.Clear();
}
////////////////////////
After CreateForNone is called, and I press F9, either
HandleOutlookToClick or HandlePhoneClick will be called, depending
which one was last called. Obviously, those menu items are still in the
program accepting keyboard shortcut, though they are not invisible.
So I replace "button.DropDownItems.Clear();" with the following
////////////////
private void ClearButtonDropdown()
{
for (int i = Button.DropDownItems.Count - 1; i >= 0; i--)
{
ToolStripMenuItem m = Button.DropDownItems[i] as
ToolStripMenuItem;
Button.DropDownItems.Remove(m);
m.Dispose();
}
Button.DropDownItems.Clear();
// even GC.Collect() will not have effect.
}
///////////////
However, strange things remain the same.
Obviously someone is still holding references to those menu items,
stopping GC from disposing those items.
Can you point out how to dispose these menu items?
Cheers
Andy Tag: Hide Tabpage Tag: 107973
I have a TabStipControl...
How do I do to hide some tabpage programmaticaly ?