|
Are you wanting to paint bitmaps onto the screen or will the program create the image dynamically? If the former then just use the BitMap functions to load and display each image on the screen as required. If the latter then there will be some more code required to calculate where to paint your dots. In either case there are many tutorials on CP about displaying/creating images to the screen.
|
|
|
|
|
Hello all..
I'm making an application which terminate other processes in different way, i.e using TerminateProcess, WM_CLOSE, WM_QUIT, SC_CLOSE.
Now i'm able to terminate process in all the way, But i need bit explanation in WM_CLOSE, WM_QUIT and SC_CLOSE.. How exactly it closes other process?? I believe there are two conditions which need to be fulfilled.
1> The target process has at least one window.
2> The target process doesn't handle the WM_CLOSE, WM_QUIT, SC_CLOSE message.
So i'm doing this to enumerates all top level windows, In LPARAM i'm passing the pid of the target process..
EnumWindows((WNDENUMPROC)Enum_Terminate_Process, (LPARAM) aiPID[i]);
And in Enum_Terminate_Process, I'm doing something like this..
BOOL CALLBACK Enum_Terminate_Process(HWND hWnd, LPARAM lParam)
{
DWORD dwID;
GetWindowThreadProcessId(hWnd, &dwID);
if(dwID == (DWORD)lParam)
{
char Title[MAX_PATH];
Title[0] = 0;
GetWindowText(hWnd, Title, sizeof(Title));
if(IsWindowEnabled(hWnd) && Title[0]!= 0 && Proc_Argument[0]!= 0)
{
if(strcmp(Proc_Argument , "-wmc") == 0)
SendMessage(hWnd, WM_CLOSE, 0, 0 );
else if(strcmp(Proc_Argument , "-wmq") == 0)
PostMessage(hWnd, WM_QUIT, 0, 0);
else if(strcmp(Proc_Argument, "-scl") == 0)
PostMessage(hWnd, WM_SYSCOMMAND,SC_CLOSE,0);
else
MessageBox(NULL,"Invalid Arguments", "Error", MB_OK);
}
}
return TRUE;
}
So i need to know whether i'm doing right?
Thanks All..
modified on Monday, September 7, 2009 4:39 AM
|
|
|
|
|
gothic_coder wrote: So i need to know whether i'm doing right?
The above looks fine, so yes you are doing it right. However, it is up to the receiving process to decide how it handles these messages, so you need to check that those processes will terminate correctly on receipt of whichever message they are sent.
|
|
|
|
|
Alright.. Thanks for confirming
|
|
|
|
|
No, it's wrong, ... in particular WM_CLOSE.
|
|
|
|
|
|
Check his post history. He does not have the capability to explain, only criticize.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi all,
i m using SDI application,
i m using worker thread for loading records in ListControl.
here i m using a modeless dialog box ,i create and display the modeless dialog before Starting the thread and hide it at end of thread.
I m start thread at OnInitialUpdate function of Formview.
my problem is that when modelss dialog box hide now the main window lost the focus.
i m use SetFocus function but its not working.
void CFormView::OnInitialUpdate()
{
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
if(Main_View->m_pmodeless)
{
m_pmodeless->SetForegroundWindow();
m_pmodeless->ShowWindow(SW_SHOW);
pMainFrame->EnableWindow(0);
m_pmodeless->EnableWindow(0);
}
else
{
m_pmodeless = new CModeless_dlg
m_pmodeless->Create(CModeless_dlg::IDD,0);
m_pmodeless->ShowWindow(SW_SHOW);
pMainFrame->EnableWindow(0);
m_pmodeless->EnableWindow(0);
}
AfxBeginThread(Initial_Thread,NULL,THREAD_PRIORITY_HIGHEST,0,0,NULL);
}
m_pmodeless->ShowWindow(SW_HIDE);
CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd();
pMainFrame->EnableWindow(1);
pMainFrame->SetFocus();
please tell me how can i setfocus on main window of sdi.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
"_$h@nky_" wrote: i m using worker thread for loading records in ListControl.
That's probably a bad idea to start with - you should only access windows from a UI thread, unless you're posting messages to the window from hte non-UI thread.
And that's also the basic reason why the SetFocus in the thread function isn't effective - as the documentation[^] says:
The window must be attached to the calling thread's message queue
Try posting a custom message to the main window at the end of the thread, indicating that the thread is finished. The main frame can handle that by dismissing the progress dialog and retrieving the focus.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Which is the right way to do and why?
TCHAR *gClassName = 0;
bool CreateCabinetMainWindow(const TCHAR* classname)
{
DeleteCabinetMainWindow( );
gClassName = (TCHAR*)classname;
}
OR
const TCHAR *gClassName = 0;
bool CreateCabinetMainWindow(const TCHAR* classname)
{
DeleteCabinetMainWindow( );
gClassName = classname;
}
Thanks in advance,
Nandu
|
|
|
|
|
Second option makes more sense.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Second one. If you're declaring gClassName as mutable, then assigning an immutable string pointer to it is a bad idea. If you try to write to gClassName, then you could easily get an access violation if you'd called CreateCabinetMainWindow like this:
if (CreateCabinetMainWindow(_T("MyClass"))) { .... };
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I have an EXE file and i want to list all the strings from the String Table of the EXE
The exe is the compiled CPP file like the one present in the Debug folder
How do i display all the strings that are present??
|
|
|
|
|
If it's just the string table you're after, load the exe into Visual Studio - you can view its resources there.
Otherwise, a nice utility called strings[^] will show you all the strings embedded in an executable.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Actually we have to write our code which will take an EXE as input and display all the strings present in that EXE.
What are the ways to do that?
|
|
|
|
|
If it's string tables in the resources, then EnumResourceNames[^] can tell you all the string tables present in a module, FindResource[^] can get you handles for those resources, which you can then access using LoadResource[^] and LockResource[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the reply
The documentation of MSDN about FindResource is not that clear,so am having problem in that.
What is the parameter lpName ([in] Specifies the name of the resource) ?
|
|
|
|
|
It's what EnumResourceNames(Ex) gives you as a parameter when calling the function you specify via the ENUMRESNAMEPROC function pointer parameter.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But ENUMRESNAMEPROC also requires lpName. what is that?
|
|
|
|
|
Noooo - when you call EnumResourceNames, it'll call the function you specify once for each name it finds. It will pass in the name it's just found, allowing you to store it somewhere or process it:
typedef std::vector<CString> Names;
BOOL CALLBACK GatherNames(
HMODULE hModule,
LPCTSTR lpszType,
LPTSTR lpszName,
LONG_PTR lParam)
{
Names* pNames = reinterpret_cast<Names*>(lParam);
pNames->push_back(CString(lpszName));
return TRUE;
}
void GetStringResourceNames(HMODULE module)
{
Names names;
EnumResourceNames(module, RT_STRING, GetherNames, reinterpret_cast<LONG_PTR>(&names));
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This is the code we are using till now. Where are we going wrong?
#include "stdafx.h"
#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "string.h"
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param);
char buffer[200];
int _tmain(int argc, _TCHAR* argv[])
{DWORD S;
LPCTSTR RT_String=NULL;
LONG_PTR aux_param=NULL;
BOOL q,r;
HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
q= MyStringCB(some_library,RT_String,buffer,aux_param);
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
return 0;
}
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param)
{ DWORD startId = ((DWORD)buffer - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{ LoadString(some_library, i,buffer,sizeof(buffer));
}
return TRUE;
}
|
|
|
|
|
Why didn't you take any notice of this answer[^] to one of your previous questions? His answer was completely accurate.
Here's what your MyStringCB should look like:
BOOL CALLBACK MyStringCB(HMODULE some_library, LPCTSTR resourceType, LPTSTR stringName, LONG_PTR aux_param)
{
_ASSERTE(resourceType == RT_STRING);
static TCHAR stringValue[2048];
UINT id;
if (IS_INTRESOURCE(stringName))
id = (UINT)stringName;
else if (_T('#') == stringName[0])
id = _tcstoul(stringName+1, 0, 10);
else
return TRUE;
DWORD startId = ((DWORD)id - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{
std::fill_n(stringValue, 2048, (TCHAR)0);
LoadString(some_library, i, stringValue, 2048);
if (_tcslen(stringValue) > 0)
{
}
}
return TRUE;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to fire a non blocking message box so that it will not interupt the code below it . and I click OK on it with some message
Trioum
|
|
|
|
|
In that case, you need to make yourself a modeless dialog box[^] on which you can put your message.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|