|
I got the answer.
Its ToolStripMenuItem.ShowDropDown() function. That was easy
Thanks,
Vipul
|
|
|
|
|
I want to add text to a transparent bitmap (in C# 2.0). The text can be black, white, or red. But it seems that when I use the DrawString method of the Graphics object it antialias the text with black. This works okay when I have white or red text and the transparent bitmap is shown over a mainly black background, but looks crap when I have black or red text and the transparent bitmap is shown over a mainly white background. (White text looks blurred, red text has black bits round edges.)
Does anyone know how to antialias to white on a transparent graphic? Or antialias to transparent properly?
(I have tried setting the bitmap to white first. Then after the text has been added, floodfilling back to transparent. Sort of works except all the closed loops in letters like o, d, b, p ... etc.)
|
|
|
|
|
I found this[^], which seems to have some work arounds, from a quick google on c# antialias problems
The link above is from fairly near the top of a loooooong list.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I don't think it's possible to generate a semi-transparent bitmap with a single alpha value per pixel which will properly render ClearType text against arbitrarily-colored backgrounds (when drawing yellow text on a black background, a particular pixel may have to be red, but when drawing on a white background it may have to be yellow).
If one refrains from ClearType-style use of colors for sub-pixel addressing, one could generate a bitmap that would depict a nicely anti-aliased font when overlaid on any background, by setting the color of any area of the bitmap which touched the letters to the font color, and varying the alpha to properly soften the edges. I don't think that's what Microsoft does, though.
Still, you might want to experiment some with the property (I forget what it's called) that switches between drawing using an alpha value, or copying an alpha value to drawn pixels).
It would be nice if there were a way of restricting drawing operations to either act only on the alpha channel, or leave the alpha channel alone while acting on color. I'm unaware of how to do those things, though.
|
|
|
|
|
Okay. After playing around with a number of options without luck I decided to try a completely different approach. What I did was to create a second (temporary) bitmap with the same dimensions as the transparent target but with a white background. I then wrote on it in black. Finally I merged this into the transparent bitmap by examing each pixel in my second bitmap and setting the corresponding pixel in the target with RGB set to the target colour and the 'A' byte set to 255 - ((old R + old G + old B) / 3). Surprisingly, this worked and gives me true antialias to transparent.
If anyone's interested I've posted the code here [^]
|
|
|
|
|
Hi
I found an issue in reading files.
My code is simple:
fFile = New System.IO.FileStream("somefile", IO.FileMode.Open, IO.FileAccess.Read)
where "somefile" is file, which is in use with another application.
When I try to execute this line I will get an error: "The process cannot access the file 'sometext' because it is being used by another process".
Notepad can open this file without problem, Wordpad can not.
Can someone explain me, how notepad reading files? Can I use this method of file reading in .NET VB, or WIN32 API ?
|
|
|
|
|
SOLVED:
fFile = New System.IO.FileStream(sFileName, IO.FileMode.Open, IO.FileAccess.Read, FileShare.ReadWrite)
FileShare.ReadWrite means I allow write access to application which is using file.
|
|
|
|
|
Hi,
I want to execute mousehover event when user pressed left mouse buttion and drag on labels.
I have added 30 labels programatically and i want to change backcolor of labels when user clicks on particular label or user click on label and drag in other labels with left buttion pressed.
Ex.: Sinerio like when we select mutiple files in explore, we pressed left buttion and drag on files they get selected.
Main problem is when we pressed left key and drag on other labels then mouseover or other evnts are not executed i.e. main problem.
Without pressed mouse left button mouseover or other events are executed. how to execute events when left buttion is pressed and drag on other labels.
Thanks
Sanjay
|
|
|
|
|
hi
how I can use / insted of . for decimal number in textbox and datagridview?
|
|
|
|
|
Simple.
If the number is 123.4 , simply type 123/4 . Problem solved.
Perhaps, if you explain what it is that you are trying to do (i.e. why you need to do this, and what you want to do with the data) it might make it easier for people to give a sensible answer.
[Edit]
Fixed a typo
[/Edit]
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Wednesday, October 28, 2009 10:39 AM
|
|
|
|
|
Hi,
have a look at the NumberFormatInfo type. You probably want to set NumberFormatInfo.NumberDecimalSeparator and use the NFI in all relevant numeric input (Parse/TryParse) and output (ToString).
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Dear developpers,
I want help i want the source code in vb.net 2005 for paint programm
this program just like or similar to the paint application which come with windows
I need it the quickly if possible don't be late for me .
best wiches
|
|
|
|
|
Demanding code is not acceptable here
only two letters away from being an asset
|
|
|
|
|
In which case, get your money out and head for rentacoder or some similar site.
jamalhamou wrote: I need it the quickly if possible don't be late for me .
Depends on how much you pay - but beware, rentacoder has a lot of cowboys
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Would you like me to send my standard contract schedule out, or would you prefer to haggle over the rates first?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Lets say I have a few rows of rectangles.
I would like my mouse to:
1. Select a rectangle using left click.
2. Shift + click to select multiple rectagles.
3. Ctrl + click to select multiple rectangles.
4. Press and hold to create a boundry and select all the rectangles within that boundary.
How should I go about? I do not have any source code now as I am still thinking how to select.
Thank you very much in advance.
|
|
|
|
|
Zar Ni wrote: How should I go about?
Try Googling for things like mouseevent and your language of choice; you will find many examples.
|
|
|
|
|
hi,
override OnKeyPress ,OnMouseClick, OnMouseMove
write a Control[] GetHittedControls(int x, int y)
if in OnMouseClick left button is pressed, set a private var LeftMouseDown = true
if in OnKeyPress Shift/Ctrl is pressed, set a private var ShiftOrCtrlPressed = true
in OnMouseMove check these two vars for true then call GetHittedControls()
in GetHittedControls iterate through all child controls of your form -> get the ClientRectanlge and call control.ClientRectangle.Contains(x,y) to indicate whether the control is focused or not..
add the control to a collection if is true and thats it ..
greets
|
|
|
|
|
Hi,
I am working on an application, which calls a WPF page in MFC exe and loads it too, but the backgound for the WPF is coming black.
here is code snippet
Declaration
using namespace System;
using namespace System::Windows;
using namespace System::Windows::Controls;
using namespace System::Windows::Media;
ref class Globals
{
public:
static System::Windows::Interop::HwndSource^ gHwndSource;
static WpfApplication1::Window1^ gwcContainer;
};
i have added in oninitdialog,
System::Windows::Interop::HwndSourceParameters^ sourceParams = gcnew System::Windows::Interop::HwndSourceParameters("MyWindowName");
sourceParams->PositionX = 20;
sourceParams->PositionY = 30;
sourceParams->ParentWindow = System::IntPtr(this->GetSafeHwnd());
sourceParams->WindowStyle = WS_VISIBLE | WS_CHILD;
System::Windows::Interop::HwndSource^ source = gcnew System::Windows::Interop::HwndSource(*sourceParams);
source->SizeToContent = System::Windows::SizeToContent::WidthAndHeight;
Globals::gwcContainer = gcnew WpfApplication1::Window1();
FrameworkElement^ myPage = Globals::gwcContainer;
source->RootVisual = myPage;
I dont want the black color around.
Any help is highly appriciated.
Thanks&Regards,
KDevloper
|
|
|
|
|
Recently I have began to receive this error message when I am trying to run or compile my programs, vb.net handles clause requires a withevents variable. This is occurring on all of my current projects that use the Handles clause. I understand that to remedy this I just need to add the Protected WithEvents Button1 As... code. My question is why is this happening since the designer should, and is, doing this in its self. is there something that is occurring with my visual studios 2008(full) that is causing this problem? Are the any other reasons that could cause this such as tourtiseSVN?
modified 8-Sep-21 21:01pm.
|
|
|
|
|
Hi,
I'm new to the CLR Profiler. When I generate 20 instances of a form while running the CLR Profiler I get the following results:
Allocated bytes: 20 instances of the form
Final heap bytes: 12 instances of the form
Objects finalized: 19 instances of the form
I would expect that an instance of the form is either in the final heap or finalized, so those numbers should count up to 20 and not 31. On the other hand, if there are indeed 31 instances (due to bad programming ), then I would expect that there are 31 instances allocated instead of 20.
Can someone help me interpret those numbers?
Thanks!
|
|
|
|
|
|
Hi,
First of all I found lot of article about this. Iam trying to solve it about few days without results.
I work on aplication, which should be something like report editor for printing.
I have a form with two scroll bars, grid and two rulers. Rulers and grid are User Controls.
For both controls I call:
Me.SetStyle(ControlStyles.AllPaintingInWmPaint + ControlStyles.UserPaint + ControlStyles.Opaque _
+ ControlStyles.OptimizedDoubleBuffer, True)
UpdateStyles() befor drawing.
The grid drawing function:
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
Dim rcPaper = New Rectangle(nGrid * nPaperOffset, nGrid * nPaperOffset, _
nPaperWidth, _
nPaperHeight)
Dim bmp As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
Dim graph As Graphics
graph = Graphics.FromImage(bmp)
' Draw paper
rcPaper.Location = rcPaper.Location + ptScrollOffset
graph.Clear(Color.DarkGray)
graph.FillRectangle(Brushes.White, rcPaper)
graph.DrawRectangle(Pens.Black, rcPaper)
' Draw the grid.
If bShowGrid Then
For x As Integer = 0 To bmp.Width Step nGrid
For y As Integer = 0 To bmp.Height Step nGrid
graph.DrawLine(m_PenGrid, x, y, x + 0.5F, y + 0.5F)
Next y
Next x
End If
e.Graphics.DrawImage(bmp, 0, 0)
' Free object added
bmp.Dispose()
graph.Dispose()
Debug.Print("Grid:OnPaint")
End Sub Ruler draw function:
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
'MyBase.OnPaint(e)
Dim bmp As New Bitmap(Me.Width, Me.Height)
Dim graph As Graphics
graph = Graphics.FromImage(bmp)
graph.Clear(Color.White)
Dim rStRect As SizeF
Dim pOrigin As New PointF
Dim string_format As New StringFormat
If eStyle = ERulerStyle.rHorizontal Then
' Horizontal ruler
Dim y1 As Integer = Me.ClientSize.Height
Dim y2 As Integer = (2 * Me.ClientSize.Height) \ 3
Dim y3 As Integer = Me.ClientSize.Height \ 3
Dim y4 As Integer = 0
Dim x As Integer = 0
For i As Integer = 0 To Me.ClientSize.Width \ nGrid
If (i + nPaperOffset) Mod nStepsPerUnit = 0 Then
'If i > 0 Then
pOrigin.X = x
pOrigin.Y = y4
string_format.Alignment = StringAlignment.Center
rStRect = graph.MeasureString(CStr((i - nPaperOffset) / nStepsPerUnit), dFont, pOrigin, string_format)
graph.DrawString(CStr((i - nPaperOffset) / nStepsPerUnit), dFont, dBrush, _
x - rStRect.Width / 2 + 1 + ptScrollOffset.X, _
y4 + ptScrollOffset.Y)
ElseIf (i + nPaperOffset) Mod (nStepsPerUnit / 2) = 0 Then
graph.DrawLine(m_PenGrid, x + ptScrollOffset.X, y1 + ptScrollOffset.Y, _
x + ptScrollOffset.X, y3 + ptScrollOffset.Y)
ElseIf (i + nPaperOffset) Mod (nStepsPerUnit / nTicksNum) = 0 Then
graph.DrawLine(m_PenGrid, x + ptScrollOffset.X, y1 + ptScrollOffset.Y, _
x + ptScrollOffset.X, y2 + ptScrollOffset.Y)
End If
x += nGrid
Next i
' Show the mouse position.
If bSelecting Then
graph.DrawLine(m_PenRulerDrawing, nX, y1, nX, 0)
Else
graph.DrawLine(m_PenRulerNormal, nX, y1, nX, 0)
End If
Else
' Vertical ruler
Dim x1 As Integer = Me.ClientSize.Width
Dim x2 As Integer = (2 * Me.ClientSize.Width) \ 3
Dim x3 As Integer = Me.ClientSize.Width \ 3
Dim x4 As Integer = 0
Dim y As Integer = 0
For i As Integer = 0 To Me.ClientSize.Height \ nGrid
If (i + nPaperOffset) Mod nStepsPerUnit = 0 Then
If i > 0 Then
pOrigin.X = x4
pOrigin.Y = y
string_format.Alignment = StringAlignment.Center
rStRect = graph.MeasureString(CStr((i - nPaperOffset) / nStepsPerUnit), dFont, pOrigin, string_format)
graph.DrawString(CStr((i - nPaperOffset) / nStepsPerUnit), dFont, _
dBrush, x4 + (nWidth - rStRect.Width) / 2 - 2 + ptScrollOffset.X, _
y - rStRect.Height / 2 + ptScrollOffset.Y)
'e.Graphics.DrawLine(m_PenGrid, x1, y, x4, y)
End If
ElseIf (i + nPaperOffset) Mod (nStepsPerUnit / 2) = 0 Then
graph.DrawLine(m_PenGrid, x1 + ptScrollOffset.X, y + ptScrollOffset.Y, _
x3 + ptScrollOffset.X, y + ptScrollOffset.Y)
ElseIf (i + nPaperOffset) Mod (nStepsPerUnit / nTicksNum) = 0 Then
graph.DrawLine(m_PenGrid, x1 + ptScrollOffset.X, y + ptScrollOffset.Y, _
x2 + ptScrollOffset.X, y + ptScrollOffset.Y)
End If
y += nGrid
Next i
' Show the mouse position.
If bSelecting Then
graph.DrawLine(m_PenRulerDrawing, x1, nY, x4, nY)
Else
graph.DrawLine(m_PenRulerNormal, x1, nY, x4, nY)
End If
End If
e.Graphics.DrawImage(bmp, 0, 0, Me.ClientSize.Width, Me.ClientSize.Height)
' Free object added
bmp.Dispose()
graph.Dispose()
Debug.Print("Scroll:OnPaint")
End Sub I handle scroll event like this:
Private Sub OnVScroll(ByVal sender As Object, ByVal e As ScrollEventArgs) Handles VScrollBar1.Scroll
ctrlVRuler.ScrollRuller(, e.NewValue)
'Debug.Print("Call ctrlVRuler.Invalidate")
'ctrlVRuler.Invalidate()
ctrlMyGrid.ScrollPaper(, e.NewValue)
'Debug.Print("Call ctrlMyGrid.Invalidate")
'ctrlMyGrid.Invalidate()
' Invalidate "parent" control
Invalidate(true)
End Sub
Then while I am running appliation and scrolling I get this text in Inmediate window:
Grid:OnPaint
Scroll:OnPaint
Grid:OnPaint
Scroll:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Scroll:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Grid:OnPaint
Scroll:OnPaint
The candency of Grid repaint is rapidly bigger.
I am quit sure I call redraw (invalidate) just from scroll event during scrolling.
What do you think about this? How can I tell GDI+ to finish one controls re-drawing and then start other?
modified on Wednesday, October 28, 2009 4:10 AM
|
|
|
|
|
I probably wouldn't be able to answer your problem even if I could read your code but I'll never know because I can't read it.
Please, please, please edit your post, highlight the code part and then click the '
code block ' widget just above the Text: box. Then apply some indentation and spacing to make the code more readable. Alternatively delete the code hit the code block widget and then cut the code from your editor and paste it between the tags added when you clicked the widget.
You are far more likely to get an answer if you do that.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Yes I see. I removed it from another thread copy/past and that causes that it lost formating.
|
|
|
|
|