|
there are several articles about that on codeproject..
Don't try it, just do it!
|
|
|
|
|
|
tina- wrote: Please tell me how to inject a dll into another process ?
By searching.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
tina- wrote: Please tell me how to inject a dll into another process ?
hacking??
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
I had a very length process(unestimated time) on my dialog box and I need
to display progress bar on the MainFrame. wht I did is start a thread on the first line of the button press event
and from the thread I will calling the Function in the MAinFrame. I am able to acces the funcion, but it did not work.
May I know, if you have any smart idea to do this...
----------------------------------------------------------------------------------
CMainFrame *pfrm = ptp->pCA; // alone works fine on button click event, but doesn't work from thread
pfrm->OnTestBar();
-------------------------------------------------------------------------------------
UINT TestPbDlg:: thPrgbar( LPVOID pParam )
{
THREADPARAMS *ptp = reinterpret_cast<THREADPARAMS *>(pParam);
CMainFrame *pfrm = ptp->pCA;
pfrm->OnTestBar();
..
}
void CMainFrame::OnTestBar()
{
CProgressBar bar(_T("Progress"), 40, 100, TRUE); //CProgressBar drived from CProgressCtrl
for (int i = 0; i <100; i++)
{
bar.StepIt();
PeekAndPump();
Sleep(10);
if (bar.GetPos()==500)
{
bar.SetStep(-1);
}
else if (bar.GetPos()==0)
{
bar.SetStep(1);
}
}
}
BOOL PeekAndPump()
{
static MSG msg;
while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) {
if (!AfxGetApp()->PumpMessage()) {
::PostQuitMessage(0);
return FALSE;
}
}
return TRUE;
}
|
|
|
|
|
ptr_Electron wrote: I am able to acces the funcion
But you shouldn't be. That defeats the whole purpose for having a secondary thread. Instead, as the secondary thread does its work, have it post "update" messages to the primary thread.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I sorry it did not work..
|
|
|
|
|
Ok.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Hi all...
I'm making an application using project sheet..I did this in MFC and successfully completed now trying in WIN32...
My problem is that whenever i press OK button(I don't want to do anything in OK button) and then when i click on other tab it gets hang...
I mean i'm using 4 tabs..If i press OK from first tab and then if i click on rest of 3 tabs it shows first tab's data.. Again when i come back to first tab from where i clicked OK and then i click to rest of the tabs it shows right data...
No matter from where i start(Whether 1st,2nd,3rd or 4th tab) the moment i press OK it gets hang for rest of the tabs, and works properly when i click to the tab from which i pressed OK...
What could be the problem???
here's my code...
Any reply will be appreciated..
#include "stdafx.h"
#include "resource.h"
HINSTANCE g_hInst;
HWND g_hwndPropSheet;
const char *job_combo[] = { "Never quit automatically",
"Do not quit if virus detected",
"Always quit"
};
const char *virus_check1[] = { "Log only",
"Disinfect (if not possible, rename file)",
"Disinfect (if not possible, delete file)",
"Rename infected file",
"Delete infected file",
"Automatic"
};
const char *virus_check2[] = { "High (short runtime)",
"Normal (normal runtime)",
"Low (long runtime)"
};
const char *virus_check3[] = { "Automatic type recognition",
"Only program files",
"User defined"
};
BOOL InitInstance(HINSTANCE, int);
HWND CreatePropSheet();
LRESULT CALLBACK Page1DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page2DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page3DlgProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK Page4DlgProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
while (GetMessage(&msg, NULL, 0, 0))
{
if(!PropSheet_IsDialogMessage(g_hwndPropSheet, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
g_hInst = hInstance;
g_hwndPropSheet = CreatePropSheet();
if(-1 == (int)g_hwndPropSheet)
{
return -1;
}
ShowWindow(g_hwndPropSheet, nCmdShow);
UpdateWindow(g_hwndPropSheet);
return TRUE;
}
LRESULT CALLBACK Page1DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
int i;
HWND hCombo;
hCombo = GetDlgItem(hdlg , IDC_COMBO1);
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
CheckDlgButton(hdlg, IDC_CHECK1, BST_CHECKED);
for(i = 0 ; i<3 ;i++)
{
SendMessage(hCombo , CB_ADDSTRING , 0 , (unsigned long)job_combo[i]);
}
SendMessage(hCombo,CB_SETCURSEL,1,0);
return TRUE;
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break ;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return IDD_PROPPAGE2;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
LRESULT CALLBACK Page2DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
break;
}
return FALSE;
}
LRESULT CALLBACK Page3DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO6, IDC_RADIO1);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
LRESULT CALLBACK Page4DlgProc(HWND hdlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
LPNMHDR lpnmhdr;
switch (uMessage)
{
case WM_INITDIALOG:
int j;
int k;
int l;
HWND hCombo1;
HWND hCombo2;
HWND hCombo3;
hCombo1 = GetDlgItem(hdlg , IDC_COMBO1);
hCombo2 = GetDlgItem(hdlg , IDC_COMBO2);
hCombo3 = GetDlgItem(hdlg , IDC_COMBO3);
for(j = 0 ; j<6 ;j++)
{
SendMessage(hCombo1 , CB_ADDSTRING , 0 , (unsigned long)virus_check1[j]);
}
SendMessage(hCombo1,CB_SETCURSEL,5,0);
for(k = 0 ; k<3 ;k++)
{
SendMessage(hCombo2 , CB_ADDSTRING , 0 , (unsigned long)virus_check2[k]);
}
SendMessage(hCombo2,CB_SETCURSEL,1,0);
for(l = 0 ; l<3 ;l++)
{
SendMessage(hCombo3 , CB_ADDSTRING , 0 , (unsigned long)virus_check3[l]);
}
SendMessage(hCombo3,CB_SETCURSEL,0,0);
CheckRadioButton(hdlg, IDC_RADIO1, IDC_RADIO6, IDC_RADIO1);
CheckDlgButton(hdlg, IDC_CHECK1, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK2, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK5, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK6, BST_CHECKED);
CheckDlgButton(hdlg, IDC_CHECK7, BST_CHECKED);
break;
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
break;
case PSN_RESET:
PostQuitMessage(0);
break;
case PSN_SETACTIVE:
return 1;
case PSN_KILLACTIVE:
return FALSE;
}
}
return FALSE;
}
int CALLBACK PSheetCallback(HWND hwndPropSheet, UINT uMsg, LPARAM lParam)
{
switch(uMsg)
{
case PSCB_PRECREATE:
{
((LPDLGTEMPLATE)lParam)->style &= ~DS_CONTEXTHELP;
return TRUE;
}
break;
case PSCB_INITIALIZED:
break;
}
return FALSE;
}
HWND CreatePropSheet()
{
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
memset(psp, 0, sizeof(PROPSHEETPAGE) * 4);
memset(&psh, 0, sizeof(PROPSHEETHEADER));
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = NULL;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE1);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = (DLGPROC)Page1DlgProc;
psp[0].pszTitle = TEXT("Job");
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = NULL;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE2);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)Page2DlgProc;
psp[1].pszTitle = TEXT("Analysis Extent");
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = NULL;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = (DLGPROC)Page3DlgProc;
psp[2].pszTitle = TEXT("Schedule");
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USETITLE;
psp[3].hInstance = NULL;
psp[3].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM1);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = (DLGPROC)Page4DlgProc;
psp[3].pszTitle = TEXT("Virus Check");
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_MODELESS;
psh.hwndParent = NULL;
psh.hInstance = g_hInst;
psh.pszIcon = NULL;
psh.pszCaption = "Automatic Virus Check";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = (PFNPROPSHEETCALLBACK)PSheetCallback;
return (HWND)PropertySheet(&psh);
}
Ash..
|
|
|
|
|
Ashish Chauhan wrote: case WM_NOTIFY: lpnmhdr = (NMHDR*)lParam; switch (lpnmhdr->code) { case PSN_APPLY: break; case PSN_RESET: PostQuitMessage(0); break; case PSN_SETACTIVE: return 1; case PSN_KILLACTIVE: return FALSE; } //break;
Your Dialog Proc for Property page is not returning the values to the property sheet handler. To set the return value, the dialog box procedure for the page must call the SetWindowLong function with the DWL_MSGRESULT value, and the dialog box procedure must return TRUE.
try the following,
case WM_NOTIFY:
lpnmhdr = (NMHDR*)lParam;
switch (lpnmhdr->code)
{
case PSN_APPLY:
SetWindowLong(hdlg, DWL_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
return TRUE;
case PSN_SETACTIVE:
SetWindowLong(hdlg, DWL_MSGRESULT, 0);
return TRUE;
case PSN_KILLACTIVE:
SetWindowLong(hdlg, DWL_MSGRESULT, FALSE);
return TRUE;
}
just for checking purpose try the above, read msdn for each Notification and write accordingly.
And also message loop has to check for OK cancel part. read msdn for PropSheet_GetCurrentPageHwnd also.
while (GetMessage(&msg, NULL, 0, 0))
{
if(PropSheet_IsDialogMessage(g_hwndPropSheet, &msg))
{
if (!PropSheet_GetCurrentPageHwnd(g_hwndPropSheet))
{
DestroyWindow(g_hwndPropSheet);
PostQuitMessage(0);
}
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
|
|
|
|
|
You got my 5 for your patience!
Maxwell Chen
|
|
|
|
|
Thanks rajkumar...
Thanks a ton...
It works now...
Thanks again...
Ash..
|
|
|
|
|
yeah, i too agree with maxwell, 5 from my side too
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
|
toxcct wrote:
come on tox! don't sleep!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
hi Experts,
i am again asking u all to one more problem. in the i add picture box but i didnt know how to add the image and what code should i add to show image when i execute that program
thanku one and all,
regards,
savitri,
|
|
|
|
|
In visual C project (MFC type) go to insert menu and select bitmap option. Browse for your picture file and add it.Under resources tab in the project navigator check the ID of the bitmap file. Then under OnPaint() function add this piece of code.
CPaintDC dc(this);
CBitmap bmp , *poldBmp;
CDC memdc;
bmp.LoadBitmap(IDB_BITMAP1); // IDB_BITMAP1 is the ID of the bitmap loaded
mdmdc.CreateCOmpatibleDC(&dc);
poldBmp= memdc.SelectObject(&bmp);
dc.BitBlt(10,10,47,47,&memdc,0,0,SRCCOPY);
memdc.SelectObject(poldBmp);
//Do not call CDialog::Onpaint() for painting
|
|
|
|
|
I think he wants to insert a image to a control(maybe static control or no).
|
|
|
|
|
savitri wrote: in the i add picture box but i didnt know how to add the image and what code should i add to show image when i execute that program
I think you are looking for Win forms help. Then I think this is not the message board, you have dedicated message board for WF.
Anyway, right click the picture box you have "Choose Image" option in the context menu. Or go to the property View and Image Option has the field to set the Image.
And if you looking for Picture Control in win32/MFC, in the property view, set the type of picture control to Bitmap, and specify the ID of the bitmap resource in the Image field
modified on Tuesday, March 4, 2008 7:47 AM
|
|
|
|
|
You can use of this code for insert image to your control.
#include AtlImage.h
CImage m;
m.Load(_T("c:\\1.jpg"));
m_Control.SetBitmap(m_.detach());
|
|
|
|
|
Hi Experts,
How can I pass a message from dll application to other application?
|
|
|
|
|
With PostMessage , of course.
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
|
|
|
|
|
What's a "dll application"?
We deal in "processes" here
Do you need to pass a message from one process to another?
If so... Interprocess Communications[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
pther wrote:
How can I pass a message from dll application to other application?
have you dll has any window, or it just one way communication!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|