|
dlls cannot be run, without a host program to run them. To run an app on reboot, put an entry in the 'runonce' key in the registry.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks a lot for the Idea. This runonce concept definetly solves my purpose.
But I am facing some issue here. I have placed a string value "E:\test\runtoadd.bat". And this batch file consists of a command which runs a registry file which inturn resets a registry key.
Then I reboot my machine and observed that the batch file and .reg are running on the reboot but the the thing is the registry key is not getting effected. Can you please let me know what is mistake here.
Thanks:
Rakesh
Rakesh
|
|
|
|
|
perhaps your batch file does not have permission to make the change ? What if yuo run it from the command line, does it change then ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes. When I run from the command prompt it changes...
Rakesh
|
|
|
|
|
As Christian says it may be a permissions problem, which registry key are you trying to change ?
|
|
|
|
|
Greetings all,
I can drag and drop a bitmap from a small picture box (pictureBox1) to a larger picture box (pictureBox2) and it works fine until a repaint, at which point the large picture box reverts back to what it was before the drag and drop. Thank you in advance. Any ideas to fix this would be appreciated. (Thanks to Rehan Nadeem for the Win32Support code!)
private void pictureBox2_DragDrop(object sender, DragEventArgs e)
{
if ((e.Data.GetDataPresent(DataFormats.Bitmap)))
{
Point largeBitmapLocation = this.pictureBox2.PointToClient(new Point(e.X, e.Y));
// 1. Get a handle to the large bitmap device context
Graphics largeBitmapDC = this.pictureBox2.CreateGraphics();
IntPtr largeBitmapHdc = largeBitmapDC.GetHdc();
// 2. Get a handle to the small bitmap device context
Bitmap smallBitmap = (Bitmap)(e.Data.GetData(DataFormats.Bitmap));
int smallBitmapHeight = smallBitmap.Height;
int smallBitmapWidth = smallBitmap.Width;
IntPtr smallBitmapHdc = Win32Support.CreateCompatibleDC(largeBitmapHdc); // in-memory
Win32Support.SelectObject(smallBitmapHdc, smallBitmap.GetHbitmap());
// 3. draw the smallBitmap on the largeBitmap
Win32Support.BitBlt(
largeBitmapHdc, // largeBitmap is target
largeBitmapLocation.X, largeBitmapLocation.Y, // destination
smallBitmapWidth, smallBitmapHeight, // source width, height
smallBitmapHdc, // smallBitmap is source
0, 0, // source x,y
Win32Support.TernaryRasterOperations.SRCCOPY);
Graphics memDC = Graphics.FromHdc(smallBitmapHdc); // for ReleaseHdc
IntPtr hMemdc = memDC.GetHdc();
memDC.ReleaseHdc(hMemdc);
largeBitmapDC.ReleaseHdc(largeBitmapHdc);
}
}
charles922
cepeasley@earthlink.net
|
|
|
|
|
charles922 wrote: this.pictureBox2.CreateGraphics();
This is why. If you create a graphics object, then as soon as the paint event is called, it will overdraw whatever you drew. Why on earth would you draw on top of a picture box, that' kind of redundant, isn't it ?
Do your drawing in the paint event, then whenever the control is invalidated, your code will draw what you want drawn.
Why are you using BitBlt instead of using the GDI+ methods ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: draw on top of a picture box
That is a bit on the redundant side...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
A lot of people seem to grab a picture box as 'the thing to use for a picture', then call CreateGraphics to draw on top of it. I'm curious to know how they find out about this method, while simultaneously completely failing to understand what it is for, is there a bad article on CP that points them in that direction ? I keep meaning to write an article on what CreateGraphics is and isn't good for, and why it's redundant to create a control, just to draw on top of it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: is there a bad article on CP that points them in that direction ?
I am not sure why it is.
Christian Graus wrote: I keep meaning to write an article on what CreateGraphics is and isn't good for, and why it's redundant to create a control, just to draw on top of it.
Go for it. You got my support
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
I havent seen a reason for this misconception either.
Is the name confusing, should it have been called an ImageBox ?
And what is next ? painting text over a TextBox ?
Anyway, I dont use PictureBox at all; I prefer to paint on a Panel.
On one hand I then have to load the image file and do the DrawImage,
on the other hand I can easily add text, borders, whatever, and have the scaling match up.
Greetings.
|
|
|
|
|
Exactly - a lot of the questions relating the picture box involve the assumption that it's a lot more than it is ( I've seen people ask about transitions like Powerpoint, for example )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
>>Why on earth would you draw on top of a picture box, that' kind of redundant, isn't it ?
Christian, thanks for your prompt response. Perhaps it is redundant. Imagine a wall full of empty photograph frames. That's the destination picture box. Now imagine a number of photographs, perhaps in a shoebox on the floor. The photos in the shoebox are the smaller bitmaps (also displayed in picture boxes) that our intrepid user will be dragging to one of the frames on the wall.
>>Do your drawing in the paint event, then whenever the control is invalidated, your code will draw what you want drawn.
Please excuse my brain malfunction. It must have been the UFO's. I had the code in the paint event, and for some reason moved it. <<insert homer="" simpson="" 'doh!'="" sound="" here="">> I put it back in the paint event and all is well now. Thanks again. (Proof that working 8 hours a day on old C code will indeed rot your brain.)
>>Why are you using BitBlt instead of using the GDI+ methods ?
Excellent question. Answer: (1) Old habits die hard (2) I had read "on the Internet" that BitBlt was so fast; however, DrawImage() is working plenty fast for me. (Lots of overloads for DrawImage() ! )
charles922
|
|
|
|
|
Hi,
I want to show how my datas make progress ,while they are being sent from My Computer to the Web Server. Here is the scenerio :
I have a web service and some pictures is being gone to the web server including my Web Service stuffs and my webservice takes the pictures and blah blah blah. and i send these pictures as byte and from my computer using a windows apps coded with c#.After i click on the send button,a little form must be appeared and show the progress how made to users. The datas are being sent to web server from my computer.as a result that i want to inform the users with a progressbar control . I hope I could descripe my problem to whom wanna help me.
Thanks in advance.
I am not a perfect programmer,but i have perfect's programmers' habits.
|
|
|
|
|
atarikg wrote: i want to inform the users with a progressbar control
Just do it then. What exactly is your question? Opening a little form when you click on a button is very easy to do. Are you trying to figure out how to update the data flow metrics to the progressbar control?
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
yeap. This is what exactly i want.
How can i do that ?
Paul Conrad wrote: Are you trying to figure out how to update the data flow metrics to the progressbar control?
I am not a perfect programmer,but i have perfect's programmers' habits.
|
|
|
|
|
What I want to do is programmically assign a Form to be displayed on a specific monitor connected to my computer. Say that I have more than one video card in my computer, what I wish to do is choose which card displays a Form.
I've been looking at the Screen[^] class, and it seems to have the functionality I need. Some code snippets I've found here and there show to take the Bounds property of a specific Screen and assign its value to the Bounds property of a Form . The Form will then be displayed in the specified screen.
However, the above, I think, assumes a multi-monitor situation in which the desktop is being displayed across two or more monitors. That's not my situation. I want to have more than one monitor that are independent of each other. The idea ultimately is to have a video being displayed on one form using Managed DirectX and another video being displayed on another form, both in full screen mode (and on seperate screens).
Unfortunately, I only have one monitor connected to my computer at this time, or I would experiment to see what happens. Before I go out and purchase a second video card, I thought I would post my query here to see if anyone can offer any insights into how I can accomplish what I described above. Thanks for your time.
|
|
|
|
|
Hi Leslie,
I dont have all the info, but here is some:
1.
in desktop-across-multiple-monitors, you get one large desktop, and the coordinates of
your Form decide where it will appear i.e. on which monitor(s), it could be split
over more than one. They dont have to have same dimension, nor same settings.
Task bar would be in primary monitor. IIRC maximize expands the form to a single monitor,
the one it occupied most or something like that.
2.
what is against multi-monitor desktop ? You can still have one form fill the first monitor,
another form fill the second monitor (etc etc)
3.
lots of laptops have a video out connector, often with a separate video controller
behind it. My Dell Inspiron can switch between off, same image as own monitor, or
separate monitor; so you could combine your monitor with someone's laptop and experiment.
Hope this helps
|
|
|
|
|
Luc Pattyn wrote: what is against multi-monitor desktop ? You can still have one form fill the first monitor,
another form fill the second monitor (etc etc)
My goal is to give a multi-media presentation in which I have one or more screens in the background playing videos. When the videos are not playing, the screens should be blank, i.e. not showing the desktop. I don't want the audience being able to see the mouse moving around or elements of the desktop on the screen.
One obvious way to prevent this would be to switch off the display devices when there's no media playing, but I'd like to automate this as much as possible from the computer. Blanking out the screens may be possible using a mult-monitor set up, though.
Luc Pattyn wrote: lots of laptops have a video out connector, often with a separate video controller
behind it. My Dell Inspiron can switch between off, same image as own monitor, or
separate monitor; so you could combine your monitor with someone's laptop and experiment.
That's a good suggestion, thanks.
At this point, I'm doing research for a client I've done work for in the past. If I can demonstrate that I can create the type of functionality I described above, I'll be able to move forward and do the job for them.
|
|
|
|
|
Hi Leslie,
some more ideas:
- you could create an app (or a service !) that shows several borderless windows, backcolor
or backimage of your choosibg, each completely filling one secondary monitor.
- Maybe, dont know, that app/service can hide the mouse when hovered,
even if not the active window.
- Not sure: you might be able to move the monitors apart from each other, i.e. have
gaps in the desktop, reducing the chance the mouse ever gets on a secondary monitor.
- if you first add all monitors to the desktop, give them their intended relative position,
then remove the desktop from them, then maybe, just maybe, they retain their coordinates
and you can still show windows at those positions. (I dont know how else you would ever
get anything to show on a monitor that is not part of the desktop !).
Extra info:
I have some code that uses EnumDisplaySettings and ChangeDisplaySettings; I use it
to programmatically modify my monitor's resolution (for reading small print !).
It would be easily modified to modify some other parameters for secondary monitors, so you
could effectively move them to the extreme corner of the 64K*64K virtual desktop;
and probably could blank them as well. I did not immediately see the "extend my desktop" bit
in the DEVMODE struct, maybe it is there, maybe not.
I feel confident your goal is technically within reach.
|
|
|
|
|
I've had some luck with this issue. Here a couple of code snippets:
protected override void OnLoad(EventArgs e)
{
foreach(Screen s in Screen.AllScreens)
{
if(s.Primary)
{
Debug.Assert(primaryScreen == null);
primaryScreen = s;
}
else
{
secondaryScreens.Add(s);
}
}
Debug.Assert(primaryScreen != null);
base.OnLoad(e);
}
This is in the main form. It goes through all of the "Screens" available on the desktop, storing the secondary screens in a collection.
if(video != null)
{
video.Dispose();
video = null;
}
video = new Video(openFileDialog1.FileName);
video.Owner = videoForm;
if(secondaryScreens.Count > 0)
{
videoForm.Bounds = secondaryScreens[0].Bounds;
video.Fullscreen = true;
}
videoForm.Show();
The above is from a method that handles opening a dialog box and letting the user choose which video to play. If there are any secondary monitors available, the first one is chosen and the video will display in a Form set up to display in the second monitor in full screen mode.
The code was written quickly and could use some improvement. I was just anxious to get something working as a proof of concept. Fortunately, it works. As far as blacking out the secondary monitor, that's easy enough by making the videoForm 's background color black.
So far so good. The only problem with the above is that it requires that the secondary monitor be part of the virtual desktop. There may be situations in which I need to display a video on a device not part of the desktop. Oh well. A little bit of progress at a time...
|
|
|
|
|
I'll have to remember this if I ever jump over to dual monitor. Thanks for sharing
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi,
I am using datagridview control on my usercontrol. And I want to set datagridview control's row as deselected using
DataGridView1SelectedRows[0].Selected = false;
I have a function call bind grid which returns dataset and in usercontrol;s load event I bind it with datagridview. and next line is
DataGridView1SelectedRows[0].Selected = false;
but at this point runtime gives me an error like below...
first error message is " Index was out of range. Must be non-negative and less than the size of the collection."
Actual Error message is "this code has called into another method, when that function is finished, this is the next statement to be executed"
if anybody has any idea then please let me know...
Thanks Code project...
It People..
|
|
|
|
|
I would like to develop a feature from Linux Xserver that makes it possible to resize the currently active window by holding down a key sequence and drag the mouse. My problem is that I need to use the unmanaged Windows API to do that, and I can't get it to work.
I've tried to use a global mouse hook and get the window handles from under the mouse, but I could only get X,Y coordinates, and not a usable window handle.
Do you have any ideas on how to do this?
Edit: I used this to get the X,Y coordinates, but it's only a local hook (but I get a usable window handle, but since it's local, I only get the handle on the form, and not any other window)
How to set a Windows hook in Visual C# .NET
|
|
|
|
|
Hello There,
Can anyone let me know how can we add a row to a datagrid/datagridview control on the click of a button. The problem we face is that we can add the combobox once, but on further clicks the comboboxes are getting added in a separate column of the grid rather than the same column.
I hope I am clear with my doubt. A link to a sample app can also help me immensely
Thanks and regards,
ATUL
|
|
|
|
|