I just want to start by saying that i have been out of the programming game for a while and i just started to do a little work on a old project of mine. All i want to do is be make a listbox recognize when more than one key is pressed. To be exact, i want ctrl+A to do a select all in the listbox. I figure that .NET has something that i do not know about that is builtin to make this task easy. Thank you for a help that is provided.
Pugman812
Posts
-
Recognize Multiple keys being pressed -
Drawing a bitmapok i understand what i need to do but how do i go about making a copy of the background to a bitmap. If i was programming in vb this would take me like 2 seconds but i want to learn c because i have always known and can tell now that its a more powerful language. I appreciate any help thank you.
-
Drawing a bitmapI am new to c++. i understand programming i am a advanced vb programmer, but i am just havin problems learning and applying all these new keywords. i am a beginnering in c but i have had experience with the very basic fundamental things. i am reading through a book and they want me to draw a single bitmap on a client window and have it jump around on the window and not go out of the window boundries. The only thing that happens right now is it just draws it over and over all over the screen without removing the previous instance of the bitmap. THIS IS MY CODE.
void Game_Run() { //the is called once ever frame //do not include your own loop here! int x = 0, y = 0; RECT rect; GetClientRect(global_hwnd, &rect); if (rect.right > 0) { x = rand() % (rect.right - rect.left); y = rand() % (rect.bottom - rect.top); DrawBitmap(global_hdc, "c.bmp", x, y); } }
void DrawBitmap(HDC hdcDest, char *filename, int x, int y) { HBITMAP image; BITMAP bm; HDC hdcMem; //load the bitmap image image = LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); //read the bitmaps properties GetObject(image, sizeof(BITMAP), &bm); //create a device context for the bitmap hdcMem = CreateCompatibleDC(global_hdc); SelectObject(hdcMem, image); //draw the bitmap to the window ( bit block transfer) BitBlt( global_hdc, //destination device context x,y, //x,y location on destination bm.bmWidth, bm.bmHeight, //width, height of source bitmap hdcMem, //source bitmap device context 0,0, //start x,y on source bitmap SRCCOPY); //blit method //delete the device context and bitmap DeleteDC(hdcMem); DeleteObject((HBITMAP)image); ShowWindow(global_hwnd, SW_SHOW); }
all i need it to do is draw once and move around the screen with the rand() function. Any help would be great because this is not a essential task of the book but i like to know how to anything with the language i am learning. THANK YOU. -
itemdataI am working with a list box and i was wondering what the equivalent is in .net to list1.itemdata(1) = 2. thank you for any help
-
Omnipass password recognitionI had a feeling that what would be said because thats what i would say. I was just hoping maybe someone has already crossed that bridge. Thank you
-
Omnipass password recognitionOmnipass is software that comes with the APC biopod fingerprint scanner. This program can differenciate between password fields and none. This carries over to most software programs and the web. I recently completed a program that requires you to login with a password and i would like to login with the Omnipass software. But the Software does not recognize my form as having a password field on it. I just want to see if anyone knows what i can do to make omnipass recognize my program. Thank you
-
Portability ErrorThanks that worked great but how could you do this through code to register it at machine that it installs on. And how could i the my program check to see if it is already registered with that machine. Thank you
-
Portability ErrorI have compiled a program and made a install file. I have 3 dependencys to my program. I am working with .NET. The other computer has been updated to .net Architecture. One dependency is an .ocx file that i have installed into the windows directory. The .ocx is a user control that is been created in 6.0 and i am referencing to this. When i reference to this .ocx it makes 2 references. After i build the project. there are 2 dll's in the folder with my .exe. Thats fine. If you move the .ocx file out of the windows folder the app does not work. So i know that the app is looking for the .ocx file in the windows folder. Its just when i install this app on another machine it instant instantly says there has been an exception that can no be handled. Then i try the same install on my computer where i have made the 2 programs and it works fine. I just dont get it because all the files that are dependencys are there and the .ocx file is in its place when i run the install program. I just dont understand why it would not work on another machine with everything in its place with .net framework installed. Any help on this portability issue would be greatly appreciated. Thank you
-
Mimic rtlMoveMemory for SpeedI have replaced most of the for loops with Array.Copy to mimic the functions of the dll call. But this did not have the speed increase that i was looking for. still same processor time at 100 for 3 seconds. I have also tried a few things like encrypting a 1.4 meg file with the 6.0 version of the blowfish program and it takes seconds. I try with the .Net conversion and it take around 10 minutes to do the same thing. Throughout the conversion of this 6.0 project i have had to make many sub procedures to mimic the function of this dll. I believe the extensive use of this procedures are what is slowing me down. The function is pretty cool if i work in .net. I need an outside call to do some of the work for me because my app is straining a little to hard. I need something that does the same thing that the rtlMoveMemory does when you send it something like this
Public Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Dim LongValue as Long = 1415936116 Dim BB() as Byte CopyMemory( BB(0), LongValue , 4)
and what this does is turn this number into binary looks like this BB(0) = 116 : BB(1) = 120 : BB(2) = 101 : BB(3) = 84 in the byte array. I also need a function that does this process in reverse. I had to mimic this with extensive for loops to check each bit. If i could find an outside call to do this same thing. I also found out if the value is greater than 2147483648 which is 2 ^ 31 and is also the highest value bit in a 32 bit number. the function causes the value to go negative and subtract any other amount that the bits equal preceding that last bit. If there is any outside funtion can be used that would speed up my code. I really need to know because with the .net conversion that i am using now. If i didnt have a 6000 RPM Fan i would cook my P4 2.8 GHZ Processor. Oh yes a article on application throttling would be great too if anyone knows where i could read one. -
rtlMoveMemory Dll Call Problem In .NETI figured out fully the functions of this call through the use of for loops. This is great but there is a speed issue when handling the functions of this dll through for loops. I am just wandering if annoy one knows how to make this call work in .NET. The declare in vb 6.0 is
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
This is what i am having to work with. As anyone should know that the datatype is not supported in .net. So i replaced it with the Object datatype. a call to this dll function looks like thisDim bytearray(3) as Byte dim bytearray2(3) as Byte Copymemory(bytearray(0), bytearray2(0), 4)
This function copys all data starting with bytearray2(0) to bytearray(0) then bytearray2(1) to bytearray(1) and so on until it copys 4 times. As you can see this can be done with a for loop. But say you have to run thought that for loop 1000 times. The Dll call is much more efficient. When i do it in the manner that i am now my processor sits at 100 percent for almost 3 seconds while it goes through these loops. In 6.0 using the dll call there is no wait and no processor jump. I need this call to work for program efficiency. Any help would be great. Thank you -
VarPtr Functioni am tryin to convert a project that was made in 6.0 to .net and its a little tough. I was wondering if anyone knew of a way to mimic the function of the varptr in some way. i have been trying to use the RTLmoveMemory dll call but in .net it is almost impossible to make it function. So i have been working to figure out how this function actually works. I would say i have it almost 75 percent pinned but when you send negative numbers to it comes back with numbers that i havent been able to put a mathmatical equation too. If there is any help with that it would be great.
Public Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
but anycase i need to know how to use the varptr function because in the following snippet heres the problem and the reason i need to use itFor i = 0 To (ROUNDS + 1) dataX = 0 For K = 0 To 3 Call CopyMem(ByVal VarPtr(dataX) + 1, dataX, 3) dataX = (dataX Or Key(j)) j = j + 1 If (j >= KeyLength) Then j = 0 Next m_pBox(i) = m_pBox(i) Xor dataX Next
rounds = 16 key contains a unicode work "text1" key(0) = 116 key(1) = 101 key(2) = 120 key(3) = 116 key(4) = 49 when it first interates through the second for loop datax = 116 which is the first number in the byte array but i have no idea where these other numbers are coming from 2 datax = 298313 3 datax = 7632253 4 datax = 1953856893 if i can figure out what varptr(datax) + 1 does and mimic its function and also figure out why when negative numbers are send to the api call it sends back really negative large numbers. Any help with any thing seen here would be awesome. thank you very much -
variable pointers in .neti need to know of a way to make other variables pointers in vb.net. Is there anyway to do this. I know in 6.0 you could use the strptr or objptr or varptr. I need to know how to do this same function in .net.
-
kernel32.dll Call ProblemsWhat suggestions do you have for the replacements for my current code.
-
kernel32.dll Call ProblemsThis is a blowfish cryptography program that i am converting from 6.0 to .NET. This project has to 2 Textboxs "Textbox1, Textbox2" 2 buttons "btnEncrypt, btnDecrypt" and 1 active X control named VbCryptoEngine1 This program begins when you click the encrypt button
Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click VbCryptoEngine1.CryptAlgorithm = CryptoEngine.vbCryptoEngine.enuCRYPTO_ALGORITHMS.acuBlowfish TextBox2.Text = VbCryptoEngine1.EncryptString(TextBox1.Text, VbCryptoEngine1.key, True) End Sub
The VbCryptoEngine1.CryptAlgorithm line works fine it sets a new instance of the class blowfish where all the code for blowfish is contained. the function EncryptString looks like thisPublic Function EncryptString(ByVal Text As String, Optional ByVal Key As String = "Cool", _ Optional ByVal OutputInHex As Boolean = False) As String On Error GoTo errhandler If m_status = STAT_BUSY Or m_status = STAT_ERROR Then Exit Function EncryptString = m_Engine.EncryptString(Text, Key, OutputInHex) m_status = STAT_READY RaiseEvent statuschanged(m_status) Exit Function errhandler: ' --------------------------------------------------------------------------- ' Raise friendly error to the handler ' --------------------------------------------------------------------------- Call Err.Raise(Err.Number, "CryptoEngine:EncryptString", Err.Description) End Function
I was going to us the try catch statement but i will update code later. the line with the blue sends the string info and a few other variables to the instances blowfish class The Function looks like thisPublic Function EncryptString(ByVal Text As String, Optional ByVal Key As String = "Cool", Optional ByVal OutputInHex As Boolean = False) As String Implements IAlgorithm.EncryptString Dim ByteArray() As Byte Dim [unicode] As Encoding = Encoding.Unicode Dim ascii As Encoding = Encoding.ASCII Dim unicodebytes As Byte() Dim asciibytes As Byte() m_status = STAT_BUSY RaiseEvent statuschanged(m_status) On Error GoTo errhandler unicodebytes = [unicode].GetBytes(Text) Encoding.Convert([unicode], Encoding.Default, unicodebytes) ByteArray = unicodebytes
-
kernel32.dll Call ProblemsI am tring to use the copymemory API and it works fine in vb 6.0 but when i try to use this in .net. It throws an error and says that the object is not set to an instance. The API is declared in a public module and you do not have to instance a module. Well i never have and i have also tried putting the call in the class im working in. Still nothing. I have tried many variations in the coding of the call to satisfy its needs but always throws the error. This is the code that i am using in .NET
Public Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByVal Destination As Int32, ByRef Source As Object, ByVal Length As Int32)
This is the code that works in 6.0Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any,ByVal Length As Long)
And also is the a equivalent of the any data type in 6.0 Object in a manner of speaking. -
Unicode ConvertingI am making a blowfish cryptography program in vb .NET and i have run into a point where i have to convert for unicode. I tried using the StrConv() function but it no long support vbFromUnicode enum. I can convert to unicode but i just need to convert back in .Net. The code that i am using in 6.0 is
Key() = StrConv(New_Value, vbFromUnicode)
Any help with this would be great. -
Program SecurityI just wanted to add password security for my application. But i want to use an existing algorithm like blowfish or best suggestion. I just want a push in the right direction for this implementation.
-
Datagrid ControlI was working with a datagrid control connecting to a small 3 column access database. I have everything working but i have a save button and i want the save button to become active right when you edit something in on of the fields. I have accomplished this by using a timer and saying
if dataset.haschanges then btnsave.enable = true end if
But this only enables the button when you stop editing that cell i want the button to become active right when the editing begins. Thank you -
Access Database Errorsorry about that. I make the connection with jet 4.0 and i use a data adapter and im still good but when i try to generate the dataset it throws an error. The problem only happens when i try to access databases that i have created. When i use a database from example code it works fine. It must be something in the formatting of the database.
-
Access Database ErrorI created a simple database with 3 fields in it. When i tried to access it through VB.NET it says unknown data and will not let me go any further. any information on how to correct this problem would be appreciated. Thank you