Hi, Use GetObject API The GetObject function retrieves information for the specified graphics object. int GetObject( HGDIOBJ hgdiobj, // handle to graphics object int cbBuffer, // size of buffer for object information LPVOID lpvObject // buffer for object information );
Jitendra gangwar
Posts
-
calculate the size of HBITMAP -
notepad applicationHi, The best way is to use the MFC framework and choose the SDI application templete...most of the functionality is alreay implemented in the same. or you can refer the sample source code provided in the MSDN for the notepad application. all the best. Jitendra.;)
-
Windows ServicesHi, As far as my i know, windows services can only run on NT/2k/XP onwords. we can't deploy windows/NT services on windows 98 and on linux too. but we can utilize the same functionality by running as a background process or demon. Cheers Jitendra. Jitendra Pal Singh Gangwar E-mail: jitendra_gangwar@hotmail.com Mobile No: 09831352305
-
How to set default radio button in MFCI think you should do all this in OnInitDialog() in place of OnCreate. Jitendra.
-
Opening a bitmapHi, You should use Device-Independent Bitmaps rather Device-Dependent Bitmaps. it might solve your problem. Jitendra.
-
Opening a bitmapHi, You should you Device-Independent Bitmaps rather Device-Dependent Bitmaps. it might solve your problem. Jitendra.
-
Minimum pane size in a CSplitterWndHello all, I am using a CSplitterWnd. I would like to prevent the user from dragging the splitter any closer than a certain distance from the edge of the window. I found that CSplitterWnd::SetRowInfo() and CSplitterWnd::SetColInfo() allow you to set a "minimum" size. However, it's not the case that the user can't drag the splitter past this minimum. It's just that if he does so drag the splitter, the window size will become 0. Is there a way to do what I wish and pysically disallow the splitter to move past a certain point? Thanks, Jitendra
-
Main MFC and its Threadstry PostMessage in place of PostThreadMessage. As I understand, Here you want to notify the main application when the data is received by the thread. so it would be the right option to use PostMessage for posting the messages to the main application window. You can you the pointer to the Main application windows/ Dialog whatever the UserInterce Object to which you want to be updated. You can implement it easily - the steps is as follows 1. define a user defined Message. 2. provide the handler associated with that message in the UserInterface object (Application Window/ Dialog) 3. use PostMessage as you receive the data in Thread. enjoy ;) Jitendra
-
Shutdown messageBut according to the MSDN ---> System Shutdown Messages The following messages are used with system shutdown. WM_ENDSESSION WM_QUERYENDSESSION Thanks Jitendra:)
-
Single Instance restrictionTask Manager is an example of a program that enumerates all running processes. It is implemented using data from the performance registry. The following sample code uses the EnumProcesses function to enumerate the current processes in the system. This method is easier than using the performance registry. #include #include #include "psapi.h" void PrintProcessNameAndID( DWORD processID ) { char szProcessName[MAX_PATH] = "unknown"; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) ); } } // Print the process name and identifier. printf( "%s (Process ID: %u)\n", szProcessName, processID ); CloseHandle( hProcess ); } void main( ) { // Get the list of process identifiers. DWORD aProcesses[1024], cbNeeded, cProcesses; unsigned int i; if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return; // Calculate how many process identifiers were returned. cProcesses = cbNeeded / sizeof(DWORD); // Print the name and process identifier for each process. for ( i = 0; i < cProcesses; i++ ) PrintProcessNameAndID( aProcesses[i] ); } The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintProcessNameAndID function, passing it the process identifier. PrintProcessNameAndID in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Next, PrintProcessNameAndID calls the EnumProcessModules function to obtain the module handles. Finally, PrintProcessNameAndID calls the GetModuleBaseName function to obtain the name of the executable file. This may help u. /jitendra :laugh: Jitendra Pal Singh Gangwar E-mail: jitendra_gangwar@hotmail.com Mobile No: 09831352305
-
Single Instance restrictionTask Manager is an example of a program that enumerates all running processes. It is implemented using data from the performance registry. The following sample code uses the EnumProcesses function to enumerate the current processes in the system. This method is easier than using the performance registry. #include #include #include "psapi.h" void PrintProcessNameAndID( DWORD processID ) { char szProcessName[MAX_PATH] = "unknown"; // Get a handle to the process. HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID ); // Get the process name. if ( hProcess ) { HMODULE hMod; DWORD cbNeeded; if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), &cbNeeded) ) { GetModuleBaseName( hProcess, hMod, szProcessName, sizeof(szProcessName) ); } } // Print the process name and identifier. printf( "%s (Process ID: %u)\n", szProcessName, processID ); CloseHandle( hProcess ); } void main( ) { // Get the list of process identifiers. DWORD aProcesses[1024], cbNeeded, cProcesses; unsigned int i; if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) return; // Calculate how many process identifiers were returned. cProcesses = cbNeeded / sizeof(DWORD); // Print the name and process identifier for each process. for ( i = 0; i < cProcesses; i++ ) PrintProcessNameAndID( aProcesses[i] ); } The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintProcessNameAndID function, passing it the process identifier. PrintProcessNameAndID in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Next, PrintProcessNameAndID calls the EnumProcessModules function to obtain the module handles. Finally, PrintProcessNameAndID calls the GetModuleBaseName function to obtain the name of the executable file. This may help u. /jitendra :laugh:
-
Export DLL to two processesYour thought is absolutely vaild becasue each application loads the dll in its process space. I think it will work. jitendra:-O
-
Call another program from my project ??ShellExecute (...) Try above mantioned Win32 Shell API. Jitendra :)
-
Sockets and Active XIn your first question you have asked, as I understand that you want to read/write operations on a same socket. it is absolutely valid. When a client connect to the server. The server accepts it and a new socket is created that represent the client socket on the server. In tern when you write something on it in the server, is send to the client for the reading. And when client write something, that is sent to the server and the server can read that content on the same socket that is representing the client. According to the second question, you are using the CSocket class of MFC. The CSocket provides the various notifications on the socket like something is received or sent on the socket. These notifications Functions are inherited from its base class CAsyncSocket. And you can override these functions to get the processing done of these notifications. You don't have to you the thread manually in your application for that processing. The MFC Framework already implements it. But if the SDK/Win32 API programming is the choice than you have to manually implement all this functionality. You can find an example app based on CSocket implementation in MSDN at the below link. Hope it would help you. Jitendra
-
Passing classes into threadsThat is all right.Thanks for correcting me. The memory violation that you are facing may be due to that you are creating a local object.when you are creating the thread and passing the pointer of it. but after creation of thread, the control come back in the main function and the local object will got out of scope.still the thread is running and trying to access it by the pointer and cause the memory violation. if this is a problem then you can allocate the object by 'new' operator. so when you don't want it you can deallocate it manually. Jitendra
-
Passing classes into threadsDid some modification in your existing code. This would help you. For the passing parameter to thread, first cast it to DWORD and receive it in callback handler of thread,cast it back to its original type,now use it as you want. void main(void){ DWORD loadPerThrdID; HANDLE loadPerThrd; TCHAR szMsg[80]; DWORD dwThrdParam; static WmiWrapper Wmi(NULL, NULL, NULL); //Creating object loadPerThrd = CreateThread( NULL, 0, loadPerThrdFunc, //&dwThrdParam, (DWORD) &Wmi, //Pass the object pointer as a thread parameter. 0, &loadPerThrdID); if(loadPerThrd == NULL){ wsprintf(szMsg, (TEXT("Create Thread failed for LoadPercentage"))); MessageBox(NULL, szMsg, NULL, MB_OK); } else{ _getch(); CloseHandle(loadPerThrd); } } //Threads function DWORD WINAPI loadPerThrdFunc (DWORD param1) { WmiWrapper* wmi = (WmiWrapper*) param1; //Now you can use this wmi class pointer. ................ } Jitendra
-
Restarting a running programI am agree with you. Thanks for correcting me.
-
Restarting a running programsuhredayan® wrote: If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. If PostQuitMessage(NULL) is called from within a userinterface thread which is one of the many, within your application. It just posts a WM_QUIT message to the thread’s message queue and returns immediately; the function simply indicates to the system that the thread is requesting to quit at some time in the future. But according to MSDN -- Remarks The WM_QUIT message is not associated with a window and therefore will never be received through a window's window procedure. It is retrieved only by the GetMessage or PeekMessage functions. Do not post the WM_QUIT message using the PostMessage function; use PostQuitMessage.
-
IsConnected to internettake a try... InternetCheckConnection(...) jitendra
-
Restarting a running programPostQuitMessage(NULL) would be the better choice then PostMessage(hWnd,WM_QUIT,NULL,NULL); jitendra