|
Thanks creating a blank stretchec bitmap from a blank transparent png and drawing on it worked. Thanks for the help!
|
|
|
|
|
Omnicoder wrote: creating a blank stretchec bitmap from a blank transparent png
Why would you do that? Just create a new empty bitmap...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have a data input form (Name, address, phone, etc) (Form2) that is launched from the main page (Form1). I want to use the same form for both add and edit functions - is there a way i can do something like this:
["Add New User" button pressed on Form1]
Form2.Show()
(Form2 Loads...)
If.....then...
btnAddNewUser.Visible = True
btnEditUser.Visible = False
basically, for Form2 to "know" what button was pressed on Form1, and change the buttons that are visible on Form2 based on Form1 input. Global variables? Or is there a function that will automatically do this?
Thanks!
|
|
|
|
|
sarmedic wrote: basically, for Form2 to "know" what button was pressed on For
You have several options
sarmedic wrote: Global variables?
This will work, but is nasty as hell
sarmedic wrote: Or is there a function that will automatically do this?
No
The most obvious way to do this, is to pass a flag in to the constructor for your form, or if the same form is used over and over, then make it a property on the form. Why do you call Show and not Show Dialog ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am new to VB express 2008 express edition. I am working through some materials and am trying to design the form and write the coding to the following problem and am struggling greatly. Can anyone do it and I will work back from it and see where I am going wrong. I have one day to complete it.
A manager of a canteen want to write a program to calculate how much each customer has to pay. Memebers of staff are to pay VAT on their purchases but pupils do not. If the customer is a member of staff then the program will calaculate the VAT and add it to their total cost.
VAT is calculated using the formula.
VAT=0.175 * total cost
Their are 3 inputs in the program.
1 how many items the customer wants to buy,2
2 the price of each item and
3 whether the customer is a pupil or a member of staff (P for pupils and S for staff)
Output must display the total cost of the purchases, the type os customer, the amount of VAT paid and the final cost.
I would be really grateful if you could help me.
Thank you
|
|
|
|
|
Oh dear, this really isn't a good first post for the Code Project forums. You shouldn't ask us to do your homework and you probably should have started it before now.
Can anyone do it and I will work back from it and see where I am going wrong.
It would be better if you let us see what you've done, if in fact you have done anything, and then we'll take it from there. Try to post specific questions with short code snippets that illustrate any problem you may be having.
Alan.
|
|
|
|
|
This is incredibly easy. You should talk to your teacher if you're unable to understand how to do this. Someone doing this for you, is only going to mask your inability to do it, and further retard your progress in your class.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi all...
I am developing an application completely in MS_ACCESS. I have my project and the Access database at different locations e.g C:\ & D:\ resp.
Now i want to fill the combobox with two fields Srno, Name.
Help me how would I do it..
Thanks & Regards..
|
|
|
|
|
If you are really just using MS_ACCESS, this question might get more response if you posted it in the 'General Database' forum.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
|
|
|
|
|
Hi,
I would like to write a vb.net program that will programmatically position the mouse anywhere on the screen (not just the programs form) and then control the buttons and wheel. I.e. click on other applications.
Is this possible and can some please point me in the right direction.
Thanks,
Steve
|
|
|
|
|
Well, this isn't as easy as it would sound, but it is possible. The biggest problem is that control positions change along with the position of the windows you're clicking in. Also, directly controlling the mouse and simulating a click is not the way to go. You have to send the appropriate window messages to the control you're "clicking" on, without doing anything with the mouse. You have to get the handles of control windows (every control is a seperate window) to send these messages to. This means knowing the controls class type and name and how to find the correct control you want to click on.
You'd have to do research on FindWindow, SendMessage, various window messages, Windows Hooks, the CBT hook, message pumps, ...
Seriously, this is NOT a beginner level project. If you don't know this stuff, you're going to find it extremely difficult to do.
|
|
|
|
|
Thanks for you reply.
Whilst I am a beginer in this topic I have actually been programming since the days of the ZX81 (~1981), all be it as a hobby and mostly self taught, I have come across the API's you mention before. Whilst it will be hard, if feel that with a little help pointing me in the right direction I ought to be able to manage it (if it's possible from within VB.net).
I do not want to acces any partucular control on any prticular form.
Rather I want to control mouse behaviour using an input device other than a mouse, if I can do it with a keyboard' I can do it with the controller I have in mind.
I have become disabled and am looking for a more effective way of interfacing with the computer than the conventional mouse and KB.
Thanks again
Steve.
|
|
|
|
|
the fossil wrote: I do not want to acces any partucular control on any prticular form.
You don't really have a choice there. If not, you're just going to end up randomly clicking around the screen, not knowing what you're clicking on, if anything.
the fossil wrote: Rather I want to control mouse behaviour using an input device other than a mouse, if I can do it with a keyboard' I can do it with the controller I have in mind.
That changes the question considerably. Normally, this stuff is done by writing a device driver. You're driver would have to take the hardware input and generate the appropriate mouse-equivilent messages. That is outside the relm of VB.NET or C#, but is squarely in the sights of Visual C++.
|
|
|
|
|
Thanks,
That answers my question I had a feeling that would be the case but you can do so much more with vb.net now that I Thought it was worth asking the question.
Have you any idea about how I could go about getting such a device driver written?
Thanks again,
Steve.
|
|
|
|
|
Device Drivers are more of a black art. For every 1000 people you find that can write a normal application, about 1 or 2 can do device driver work.
|
|
|
|
|
|
Hi Steve,
You are right , you can use mouse_even API to control the mouse movements , you can use the same API to control the click and scroll of the mouse ,following is an example to show you the use of this API
You don't require to write a device driver for it
I was try to answer this thread long , but got some error while posting , then it skipped of my mind
Sorry for that
This is the example to move the mouse
Public Class Form1
Declare Auto Function mouse_event Lib "user32.dll" (ByVal dwflags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As Integer) As Integer
Const MOUSEEVENTF_MOVE As Int32 = &H1 ' mouse move
Const MOUSEEVENTF_LEFTDOWN As Int32 = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP As Int32 = &H4 ' left button up
Const MOUSEEVENTF_RIGHTDOWN As Int32 = &H8 ' right button down
Const MOUSEEVENTF_RIGHTUP As Int32 = &H10 ' right button up
Const MOUSEEVENTF_MIDDLEDOWN As Int32 = &H20 ' middle button down
Const MOUSEEVENTF_MIDDLEUP As Int32 = &H40 ' middle button up
Const MOUSEEVENTF_ABSOLUTE As Int32 = &H8000 ' absolute move
Const MOUSEEVENTF_WHEEL As Int32 = &H800 ' wheel button rolled
Dim x As Int32 = 50
Dim y As Int32 = 50
Dim multiPlyfactorX = 65535 / Screen.PrimaryScreen.WorkingArea.Width
Dim multiPlyfactory = 65535 / Screen.PrimaryScreen.WorkingArea.Height
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mouse_event(MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, x * multiPlyfactorX, y * multiPlyfactory, 0, 0)
x = x + 1
y = y + 1
End Sub
End Class
Here you would have noticed that i have used two variable called multiPlyfactorX , multiPlyfactory. This is because the API takes 0,0 as left-top corner and 65535,65535 as right-bottom corner
also to send a click you can use the following code
mouse_event(MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP, x * multiPlyfactorX, y * multiPlyfactory, 0, 0)
Here x,y are the co-ordinates in pixcels
I hope this helps !!
I have to move now , let me know if you need any other help / information
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Presmably this will transfer the focus to the clicked window, this is fine in some instances but in others where I want to position the cursor brfore sending text this will be a problem. Can you think of a way of returning the focus to my app. after positioning the cursor.
Thanks,
|
|
|
|
|
The control will be still with your application , just after sending the click command , write
Me.Activate()(i don't recommend its use)
this will activate your form , but if you have to enter any text in a different application the focus must be on the other application , not on your .
To make it more clear let us consider an example, if i have application "A" running it has a text box where we need to enter user name (without using a keyboard & mouse) , i will first position my mouse location on the text box (using the code i sent earlier) and we would send a mouse click (using the same code) just below the Mouse click code(now the focus is on other form (application "A")) we will write the code to send keystrokes (focus is on another form but your code will be executed , till your function ends), this keystroke would be sent to the form in focus (that is the form of application "A").
Also if you want to send keystrokes, you must use the Win32 API Called "keybd_event" defined in user32.dll , the same way we used mouse_event in previous reply.
does this make sense for you
-Regards
Bharat Jain
bharat.jain.nagpur@gmail.com
|
|
|
|
|
Thanks Bharat,
That's very clear.
I tend to use sendkeys.send rather than "keybd_event" it that OK?
Steve
|
|
|
|
|
I've come across another problem now.
I often use the forms topmost property, setting it to true, It has allways worked fine but now on this form it does not remain topmost. This happpens before any of the API's are called. Even just loading the form and moving away from that form causes it to be hidden. Any Ideas.
Thanks,
Steve
|
|
|
|
|
Don't wory, I just closed VS ran it again, reloaded the project and it works fine.
Wierd!
Steve
|
|
|
|
|
How can I create a DataTable from a System.Collections.Generic.List please?
(I am a VB newbie )
|
|
|
|
|
One way you can do this is using Reflection[^], but why do you want to do this?
|
|
|
|
|
My existing application (company application) returns data as a Generic.List. But, I need to filter the data displayed in a DataGridView. So, I need to use a DataView (which I can filter on) which gets it's data from the intended DataTable.The DataGridView then has its DataSource as the DataView.
if that makes any sense at all (hopefuly I'm on the right track)
Anyway, many thanks for the Reflection pointer. I'll start researching that right now.
|
|
|
|
|