Advertisement Jump to content
  • Advertisement

Metal Typhoon

  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Metal Typhoon

  • Rank
    Advanced Member
  1. I have a certain number of item inside a checklistbox and once i try to delete the seleted one i get a Out of range error. I do know why though but i dont know how to approach to a solution. here's what i'm doing with the code. private void btnDel_Click(object sender, System.EventArgs e) { foreach (int item in chkItems.CheckedIndices) { MessageBox.Show (this,Convert.ToString (item)); chkItems.Items.RemoveAt (item); MessageBox.Show (this,Convert.ToString (chkItems.Items.Count)); } } i need to either somehow start deleting from the bottom or i need to update the CheckIndices. Bare with me i'm a c# beginner , thank you !
  2. Metal Typhoon

    Having problem with WM_CHAR

    Quote:Original post by JohnBolton I can't help you except to say that WM_CHAR works as expected for me. That is, if I type "this is a test", I get one WM_CHAR message for each character -- 't', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', ' ', 't', 'e', 's', 't' i used to get the same thing... i have an opengl applicaton and i'm using a print function to display what is in my buffer. and when i had my main loop like this it worked. while (1) { if (PeekMessage (&Msg,NULL,0,0,PM_REMOVE)) { TranslateMessage (&Msg); DispatchMessage (&Msg); if (Msg.message == WM_QUIT) break; if (Msg.wParam == VK_ESCAPE) PostMessage (_Hwnd,WM_QUIT,0,0); } else { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); AppGui.interact (); SwapBuffers (_Hdc); } } after i changed to this... it seems to occur the problem. while (1) { PeekMessage (&Msg,NULL,0,0,PM_REMOVE); if (Msg.message == WM_QUIT) break; else { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity (); AppGui.interact (); SwapBuffers (_Hdc); TranslateMessage (&Msg); DispatchMessage (&Msg); if (Msg.wParam == VK_ESCAPE) PostMessage (_Hwnd,WM_QUIT,0,0); } }
  3. Ok. I've been trying to get the character that WM_CHAR gives me and put them into a buffer but i'm not having sucess with it.. the problem is that i get too many of the same one key that i have rapdly pressed and reased.. it's like the message queue has 10 of these messages being sent when i only press a key... not HOLD it down. is there a way that i get that one key only ??? thanks; here is some of my code. char *mBuffer = NULL; // String captured by keyboard char *mMaskBuffer = NULL; // Buffer full of masked characters bool mMasked = false; // Is the mask on or off ? bool mEnterHit = false; // Enter key was pressed ? bool mListenState = false; // Listening or not ? uint mPrintCount = 0; // Count where the current character is uint mMaxBuffer = 10; // # of maximum characters on the buffer void nInputUpdate (WPARAM Wparam) { if (mListenState) { // Case enter is pressed if (Wparam == 13) mEnterHit = true; // Case backspace is pressed if (Wparam == 8 && mPrintCount > 0) { mEnterHit = false; mPrintCount--; mBuffer[mPrintCount] = mBuffer[mPrintCount + 1]; } // Case tab is pressed if (Wparam == 9 && mPrintCount < (mMaxBuffer - 3)) { mEnterHit = false; mBuffer[mPrintCount] = mBuffer[mPrintCount + 1] = mBuffer[mPrintCount + 2] = 32; mPrintCount += 3; } // Update buffer if (mPrintCount < mMaxBuffer && Wparam != 8 && Wparam != 9 && Wparam != 13) { mEnterHit = false; if (mMasked) { mMaskBuffer[mPrintCount] = '*'; mMaskBuffer[mPrintCount + 1] = '\0'; } mBuffer[mPrintCount] = Wparam; mBuffer[mPrintCount + 1] = '\0'; mPrintCount++; } } } and i have this at the win procedure case WM_CHAR: nInputUpdate (Wparam); break;
  4. Metal Typhoon

    templates and dll

    I'm trying to to make a template function inside a dll and i need to export it. I'm manuall loading the dll file. This is what i have. #define DLLOUT extern "C" __declspec(dllexport) #define N_INPUT_ENTERSTATE 0x09 #define N_INPUT_PRINTCOUNT 0x0A #define N_INPUT_MAXBUFFER 0x0B #define N_INPUT_BUFFER 0x0C template <class type> type nGet (int Return); this compiles fine.. but if i put the DLLOUT in front of the template it gives me errors. it says (C:\DOCUMENTS AND SETTINGS\METAL TYPHOON\MY DOCUMENTS\Input\nInput.h(41) : warning C4091: '__declspec(dllexport ) ' : ignored on left of 'int' when no variable is declared) when i put it here <class type> DLLOUT type nGet ... it gives me this error (C:\DOCUMENTS AND SETTINGS\METAL TYPHOON\MY DOCUMENTS\Input\nInput.h(41) : error C2059: syntax error : 'string') Where do i put this DLLOUT in order to export it ? thank you for any help
  5. Metal Typhoon

    Centering 2d text ?

    The thing is that i also dont know.. because i use CreateFont from the Win API so that'swhy i was wondering if someone knew whre to get the width of the certain font at certain height.
  6. Metal Typhoon

    Centering 2d text ?

    i've done the same for centering 3d font a in nehe's 14th lesson but now i would like to have the same but with bitmaped fonts . Now what i would usually what's behind the code is.. (ScreenWidth / 2) - AllStringAddedTextWidth ... how do i find the width being used by CreateFont when i set the mWidth parameters as 0 ? thank you in advance [Edited by - Metal Typhoon on June 30, 2005 11:16:11 PM]
  7. Metal Typhoon

    3D programming Java

    JOgl definetly.. i sued it once to do a chess game .. while everyone else didnt finish using their way.. i finished it using java with jogl... so.. my 2 cents
  8. I've been using win api for quiet a while but i dont know how some parts of it work... like for instance.. let's say that i this class. class TLCORE { public: TLCORE (const char *Title,int Width,int Height,int Bits,int Colors,bool FullScreen); HWND mHwnd; // Window handle HDC mHdc; // Device context handle HGLRC mHrc; // Rendering context handle int mWidth; // Window's width int mHeight; // Window's height int mBits; // Window's depth int mColors; // Window's color bool mFullScreen; // Is fullscreen on ? static bool StartEngine (HINSTANCE Hinstance); // MUST BE CALLED FIRST private: // Windows Message Handling void Create (); void Destroy (); void Paint (); void Size (); void StartPixel (); // Chooses and sets pixel format friend LRESULT CALLBACK WndProc (HWND Hwnd,UINT Msg,WPARAM Wparam,LPARAM Lparam); }; ok inside the windows procedure i have this follwing code LRESULT CALLBACK WndProc (HWND Hwnd,UINT Msg,WPARAM Wparam,LPARAM Lparam) { TLCORE *Window = (TLCORE *) GetWindowLong (Hwnd,GWL_USERDATA); if (Window == NULL && Msg != WM_CREATE) return DefWindowProc (Hwnd,Msg,Wparam,Lparam); switch (Msg) { case WM_CREATE: { HINSTANCE Hinst = (HINSTANCE) GetWindowLong(Hwnd, GWL_HINSTANCE); Window = (TLCORE *) (((LPCREATESTRUCT)Lparam)->lpCreateParams); SetWindowLong(Hwnd, GWL_USERDATA, (LONG) Window); Window->mHwnd = Hwnd; Window->Create (); } break; I know the following.. when a window is being created after returning from CreateWindow it sends a message to the procedure WM_CREATE. I dont understand the fact that i'm making an instance of my class and then using GetWindowLong and then casting it.. ?? I'm VERY lost here.. and what does LPCREATESTRUCT do ?? why do i also have to cast it ? thank you very much..maybe i dindt explain myself very well..
  9. Metal Typhoon

    Reading from binary problem

    thank you very much :D going back to wrok at it now
  10. I have one program that it write a binary file.. for another program to read it and then used the data.. from within the program that writes the binary i test the structure that i'm writing , by opening the file reading the data and sending to a Out.txt file.. everything works fine... // Write File ofstream File (Filename,ios::binary); File.write ((unsigned char *) &Window,sizeof (Window)); File.close (); // Open file and write outputs t_Window Test; ifstream iFile (Filename,ios::binary); ofstream oFile ("Out.txt",ios::out); ((unsigned char *) &Test,sizeof (Test)); iFile.close (); oFile << Test.mTitle <<endl; but from within the other program i try the SAME.. i copy and pasted the same code above starting from whre it says //Open file and write ... well.. the Out.txt file surprises me.. i get a bunch of ÌÌÌÌÌÌ .. i dont know why.. this is where my problem is.. the t_Window structure has mWidth mHeight as part of the data.. if i try to write mWidth or anyother data.. it goes fine... but exept the Title.. here is the structure. typedef struct { char *mTitle; int mXCoord; int mYCoord; int mWidth; int mHeight; int mBits; int mColors; Tstyle mstyle; TState mFullScreen; t_Viewport *mViewport; } t_Window;
  11. use GetWindowLong ()to get the hinstance but before u need to get the handle. GetWindowLong (hWnd,GWL_HINSTANCE);
  12. Metal Typhoon

    Changing window style during runtime ?

    i tried the "combo" the SetWindowPos () .. then right after SetWindowLong.. but i guess i will try SetWindowLongPtr thank
  13. the topic says is all.. well.. i have this statemant... if (Msg.wParam == VK_F1) SetWindowLong (mHwnd,GWL_style,WS_POPUP); for some reason i dont get this to work.. it doesnt change from WS_OVERLAPPEDWINDOW to WS_POPUP .. if i change the statemant SetWindowLong (mHwnd,GWL_style,WS_POPUP); to anything wrong that i might be doing ?? thanks in advance
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!