gp343

Members
  • Content count

    106
  • Joined

  • Last visited

Community Reputation

101 Neutral

About gp343

  • Rank
    Member
  1. Default Values for Pure C data types?

    Guy, Thanks for all this help. I was just curious in case someone had ask me about initializing built-in types in C. Now you guys have provided good clarification for me. Thanks, Jr
  2. Hi Guys, Is there a default value for the built-in data types in Pure C? I know in Java, the default value for integer is 0 and for boolean is false. Do you know if Pure C has the same concept of initial default values? Jr
  3. Rotating from the Center of Triangle

    Brother Bob, you were absolutely correct - all I needed was another glTranslate after the glRotate. Many thanks, Jr
  4. Hi All, I do have problems rotating a Triangle using Opengl from the Center of the Triangle. Basically, I'm doing a glTranslate followed by a glRotatef followed by drawing the actual triangle however, it appears that I'm rotating from the bottom of the Triangle which is drawn or that I'm rotating from where I actually moved to in order to draw the triangle. Below is my C code that does the drawing of the Triangle and calling of the display list that the Triangle is in. My end goal here is to translate to a location, draw the Triangle, move to the center of the Triangle and rotate it. But I just cannot work it out. Any help will be appreciated. void DrawTriangle() { glBegin(GL_TRIANGLES); glColor3f(1.0f,0.0f,0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glColor3f(0.0f, 1.0f, 0.0f); glVertex3f(-0.5f, 0.0f, 0.0f); glColor3f(0.0f, 0.0f, 1.0f); glVertex3f(0.5f, 0.0f, 0.0f); glEnd(); } int DrawGLScene(GLvoid) { rquad+=0.2f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0f, 0.0f, -6.0f); glRotatef(rquad, 0.0f, 0.0f, 1.0f); glCallList(triangleList); glPopMatrix(); } Thanks, Jr
  5. C++ Test / Certification

    Is there anywhere I could test my C/C++ skills - similar to a certification for Java/C#.net? I've been learning C++ for a while, and I was wondering if there is anyway I can truely test my skills to give me a good representation of how to rate my c++ skills as beginner/intermediat/skilled programmer?
  6. Hi All, Is there a rule of thumb to follow when arranging classes(.cpp) and include headers? Why I ask is that I'm currently using visual studio 2008, C++, and the MFC. The problem I'm experiencing is with error LNK2005 - multiple symbols defined. The msdn states that I can use the /FORCE:MULTIPLE switch in the linker to resolve this problem - this has worked successfully. However, I'm curious to know if there is a general heuristic that I can follow when laying out header files and cpp files? Thanks, Jim
  7. Hi Guy, Does anybody knows how to query and read from the Win32_NTLogEvent using C++? If you can you provide an example? Thanks, Jr
  8. Steve, many many thanks for this help. It just makes me realized how little I do know about programming in windows. See, when reading the msdn on hooks, it is not clear that you need to have it in a dll. I just thought I could have one single exe that did it all. Again, many thanks for this guys.
  9. OK, I've done some more reading and have produce/updated the below sample code. I've set a break point on the first line in the GetMsgProc function. The problem is that it is not entering the GetMsgProc function when I open or close notepad. I've also tried changing the message to WH_CALLWNDPROC but it still doesn't work. At the end of the day, all I want is to be able to intercept a WM_CLOSE/WM_QUIT/WM_DESTROY. Below is my full source code. #define WIN32_LEAN_AND_MEAN // trim the excess fat from Windows #include <stdlib.h> #include <windows.h> #include <Windowsx.h> #include <tchar.h> #include <stdio.h> #include <string.h> LRESULT WINAPI GetMsgProc(UINT, WPARAM, LPARAM); DWORD WINAPI MsgLoop(LPVOID lpParameter); // Global Hook handle static HHOOK hIISHook =NULL; static HINSTANCE hinstDLL = NULL; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { HANDLE hThread; DWORD dwThread; DWORD exThread; BOOL bOK = FALSE; HWND nPad = NULL; DWORD threadId = GetCurrentThreadId(); hIISHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, NULL, threadId); bOK = (hIISHook != NULL); if (bOK) { nPad = FindWindow(_T("NotePad"), NULL); SetWindowLongPtr(nPad, GWLP_WNDPROC, GetMsgProc); MessageBox(NULL,_T("Low Level hook installed properly"), _T("Information"), MB_OK); } hThread = CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE) MsgLoop, (LPVOID) hInstance, NULL, &dwThread); if (hThread) { return WaitForSingleObject(hThread,INFINITE); } else { return 1; } UnhookWindowsHookEx(hIISHook); return 0; } DWORD WINAPI MsgLoop(LPVOID lpParameter) { MSG msg; while (GetMessage(&msg,NULL,0,0)) { switch(msg.message) { case WM_QUIT: case WM_DESTROY: break; } TranslateMessage( &msg ); DispatchMessage( &msg ); } } LRESULT WINAPI GetMsgProc(UINT nCode, WPARAM wParam, LPARAM lParam) { PMSG msg; HWND tmpHWND = NULL; int i = 0; msg = (PMSG)lParam; tmpHWND = FindWindow(_T("NotePad"), NULL); if (tmpHWND == msg->hwnd) { i = 1; } if (msg->message == WM_CLOSE || msg->message == WM_DESTROY || msg->message == WM_QUIT); { i = 2; } return CallNextHookEx(hIISHook, nCode, wParam, lParam); }
  10. Ok Guys, Is it possible to monitor an external application eg. notepad, ms word etc for Messages that they receive, i.e WM_DESTROY? I've made several attempts to write a simple C++ application that can monitor a specified application for WM_DESTROY, WM_CLOSE. I did uses the SetWindowsHooksEx and WH_GETMESSAGE function but my GetMsgProc was never called. Can someone provide an example if possible to monitor other application with Hooks? Jr
  11. Hi there, I've been trying a hook notepad using SetWindowsHookEx function and the WH_GETMESSAGE message but to no avail. Below is my current running code. My code compiles and run, the problem is that the LRESULT WINAPI GetMsgProc(UINT nCode, WPARAM wParam, LPARAM lParam) function is never called. Can somebody please help as to why that function is never executed when I start/close notepad? #define WIN32_LEAN_AND_MEAN // trim the excess fat from Windows #include <stdlib.h> #include <crtdbg.h> #include <windows.h> #include <Windowsx.h> #include <tchar.h> #include <stdio.h> #include <string.h> #include <locale.h> #include "Resource.h" LRESULT WINAPI GetMsgProc(UINT, WPARAM, LPARAM); /*Standard Dialog Call back function*/ BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); HWND hWndMainDialog; // Global Hook handle HHOOK hIISHook; HINSTANCE hinstDLL; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { BOOL bOK = FALSE; hinstDLL = LoadLibrary((LPCTSTR) _T("c:/WINDOWS/system32/notepad.exe")); hIISHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, hinstDLL, 0); bOK = (hIISHook != NULL); if (bOK) { MessageBox(NULL,_T("Low Level hook installed properly"), _T("Information"), MB_OK); }else { UnhookWindowsHookEx(hIISHook); MessageBox(NULL,_T("Error Installing Hook"), _T("Information"), MB_OK | MB_ICONSTOP); } DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG_IIS), NULL, DlgProc); UnhookWindowsHookEx(hIISHook); _CrtDumpMemoryLeaks(); return 0; } LRESULT WINAPI GetMsgProc(UINT nCode, WPARAM wParam, LPARAM lParam) { PMSG msg; msg = (PMSG)lParam; return CallNextHookEx(hIISHook, nCode, wParam, lParam); } BOOL CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { BOOL b; switch(Msg) { case WM_INITDIALOG: hWndMainDialog = hWnd; return TRUE; case WM_COMMAND: switch(HIWORD(wParam)) { case BN_CLICKED: switch(LOWORD(wParam)) { case IDC_BTN_PROCESS: b = FALSE; if(!b) { MessageBox(NULL,_T("Button has been clicked"), _T("Information"), MB_OK | MB_ICONSTOP); return; } break; } break; } return TRUE; case WM_CLOSE: PostQuitMessage(0); return TRUE; case WM_DESTROY: PostQuitMessage(0); return TRUE; } return FALSE; }
  12. Hi there, Is there a way from C/C++ on Windows to intercept a shutdown message to other applications? Basically, I'm attempting to intercept all calls to iisreset for IIS 6 and then performing some backup before the server shuts down. I'll be grateful for any help. Thanks, Jr
  13. Hi All, I have an ownerdraw ListView control. I'm trying to use an ownerdrawn ListView control to draw and display images in the second column of a listview which is set to detail view. I have overridden the DrawColumnHeader, and DrawSubItem methods as displayed below. It is drawing the icon correctly, however, when I click on a row, the middle column, eg. column 1 is not being shown as selected. All other columns look selected whenever I click on a row. Can somebody please help with having the selected row displayed correctly? private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e) { e.DrawDefault = true; } private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex == 1) { e.DrawBackground(); e.Graphics.DrawImage(e.Item.ImageList.Images[e.Item.ImageIndex], e.SubItem.Bounds.Location); e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), e.SubItem.Bounds.Location.X + this.imageListTask.Images[0].Width, e.SubItem.Bounds.Location.Y); } } Many thanks, Jr.
  14. Ok Guys, I removed the "cout<<s" statements from within the body of the while loop and the overall time dropped to 17.0 seconds. I guess after all the problem was with cout<<. I need to find a c++ work around for cout, but I'm now happy with the 17.0 secs time. Thank you all for the help you've rendered me. Regards, Jr.
  15. OK Antheus, I see you're unable of respond to a question without projecting your arrogance and introducing a undertone of insult. Nevertheless, for those who are willing to help without showing off how smart/brilliant they are, I've ran some test and the results are outlined below: The filesize of messages.log is 1.38mb, it has 12732 lines within it. C Version in Debug Mode, took 26.0 seconds C Version in Release Mode, took 26.0 seconds C+ Version Debug Mode, 1.38mb log file, took 65.0 seconds C+ Version Release Mode, 1.38mb log file, took 61.0 seconds For such a small application, I cannot imagine that one can spot significant differences between Debug / Release mode. I just thought that for such a trivial program, that there show not be any significant time differences between the C/C++ I/O? Thanks for the help, Jr.