|
Thanks for the information.
Never tried it myself.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Thanks to all for quick response.
Now my problem is solved.
MSDN itself states "Call this function to set the minimum allowable width, in pixels, of the list box of a combo box"
The problem was the very small width specified by me.
The 100 pixel size was less then the width of the combo box itself, that's why i was not able to see any change.
Thank you very much!
|
|
|
|
|
Hello all
I am making a MFC silent application which will trace if windows is shutting down or not and if it is I will have to stp this shut down and perform some other work and then initiate the shutdown myself.I am overriding method to handle WM_QUERYENDSESSION . the code is some thing like this
BOOL CMyShutDownDlg::OnQueryEndSession()
{
ShellExecuteA(NULL, "open","abc.exe", NULL, NULL, SW_SHOWNORMAL);
::MessageBox(NULL,_T("Test"),_T("I stopped shutdown"),MB_OK);
return FALSE;
}
The thing is that returning false allows window to halt the sutdown but not completely stop it. Also,while trying to file any other exe at this time leads to'windows error' stating that windows cannot execute this as it is about to shutdown. I think as soon as windows recieves WM_QUERYSHUTDOWN it sends all other applications WM_CLOSE which is what I think is stopping my aplication to execute any other application from itself.
Please help me in this .
Regards,
Kushagra
I hate coding but I luv to develop
|
|
|
|
|
The documentation for WM_QUERYENDSESSION says that the WM_ENDSESSION message is sent after the former message is processed. You could try ShellExecute in the WM_ENDSESSION handler.
The documentation also says that after 5 seconds the system displays information about the applications that are blocking shutdown so that the user can manually end the application. So I don't think you have much time here.
It's probably a good idea to review the requirements or design and look for alternatives.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_» wrote: It's probably a good idea to review the requirements or design and look for alternatives.
That's maybe used as a general advice to all the people posting here...
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]
|
|
|
|
|
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
CPallini wrote: That's maybe used as a general advice to all the people posting here...
"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
|
|
|
|
|
|
Thanks David,
It helped me out
Kushagra
|
|
|
|
|
Kushagra Tiwari wrote: BOOL CMyShutDownDlg::OnQueryEndSession()
{
ShellExecuteA(NULL, "open","abc.exe", NULL, NULL, SW_SHOWNORMAL);
::MessageBox(NULL,_T("Test"),_T("I stopped shutdown"),MB_OK);
return FALSE;
}
How about:
CMyShutDownDlg::OnQueryEndSession()
{
PostMessage(MY_MESSAGE);
return FALSE;
}
CMyShutDownDlg::MyMessageHandler()
{
ShellExecuteA(NULL, "open","abc.exe", NULL, NULL, SW_SHOWNORMAL);
} You might also consider using TRACE() instead of MessageBox() for such debugging.
"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
|
|
|
|
|
That I think was the best tweak that could be implemented
Thanks a Ton, David
Regards,
Kushagra
|
|
|
|
|
Kushagra Tiwari wrote: That I think was the best tweak that could be implemented
Maybe, but you're testing will be the ultimate judge of that. Don't discount Superman's "respond to WM_QUERYENDSESSION rather than WM_ENDSESSION " suggestion.
"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
|
|
|
|
|
Also ..If I want to distinguish betwwen a Shutdown event and a Restart event , what should be done in achieving the same ? As , WM_QUERYENDSESSION doesnot give me any differentiation between Shutdown and Restart. Is there a way to know specifically which one of the two has been initiated ??
Regards,
Kushagra
I hate coding but I luv to develop.
|
|
|
|
|
Kushagra Tiwari wrote: Is there a way to know specifically which one of the two has been initiated ??
That has been asked before, but I do not recall the answer. Have you looked at the lParam parameter?
"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
|
|
|
|
|
I want to load a pdf file on the click of a button.
In the OnClickButton() implementation I am writing the function which open the PDF file
ShellExecute(0,
"Open",
"%s\\HELP\\RiverCADPro_User_Manual.pdf",
NULL,
NULL,
SW_MAXIMIZE);
The above code is not working.What else is to be needed so as to run the above code
|
|
|
|
|
deadlyabbas wrote: "%s\\HELP\\RiverCADPro_User_Manual.pdf"
What is this "%s" on the start of the file path???
I've tested the form below and it works fine:
ShellExecute(NULL,
_T("Open"),
_T("D:\\Test.pdf"),
NULL,
NULL,
SW_MAXIMIZE);
Nuri Ismail
|
|
|
|
|
Thank You!!
Actually its a help file which I want to open on the click of help button.
Can you please tell me that how we are going to open the related bookmark.
|
|
|
|
|
Now i will give you an example code which works with Acrobat Reader. But you have to get the path to Acrobat Reader yourself and also form the command line parameters for your need. You can find information about the cmd line parameters of Acrobat Reader here[^].
Here is the example for you:
const CString strAcroPath = _T("C:\\Program Files\\Adobe\\Reader 9.0\\Reader\\AcroRd32.exe");
const CString strParameters = _T(" /A \"page=5&zoom=200&pagemode=bookmarks\" ");
const CString strFilePath = _T(" \"D:\\Test.pdf\" ");
const CString strCmdLine = strParameters + strFilePath;
ShellExecute(NULL,
_T("Open"),
strAcroPath,
strCmdLine,
NULL,
SW_MAXIMIZE);
The code above will work only on systems with Adobe Acrobat Reader installed!!!
If you want to support other readers you have to find information whether they support cmd line parameters and if yes then what is the exact syntax.
I hope this helps!
Nuri Ismail
|
|
|
|
|
deadlyabbas wrote: The above code is not working.
What does it mean, exactly?
Do you know ShellExecute has a return value?
deadlyabbas wrote: "%s\\HELP\\RiverCADPro_User_Manual.pdf",
deadlyabbas wrote: What else is to be needed so as to run the above code
See documentation [^] for the requirements (of course you need also PDF reader application).
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]
|
|
|
|
|
Thanks Once again.
Actually I want to get the registry path where the .exe of Acrobat reader is.
So that I can pass the command line arguments to it ...........
Because to open a PDF with sppecific book mark I need the exe path and by command line argument I will pass the page number to it.
Like wise we do in Delphi
HelpFilePath : String;
DoesFileexists : Boolean;
CommandLine : String;
ExePath : String;
IsAcroExeLocated : Integer;
ButtonSelected : Boolean;
AcroVersion : String;
//Extracting Acrobat executable file path from Registry
// replace the double quotes and %1 from the string
ExePath := AnsiReplaceStr(GetRegistryValue('\AcroExch.Document\Shell\Open\Command'),'"','');
ExePath := AnsiReplaceStr(ExePath,'%1','');
// creating the help file path from WaterNET.exe path and file name
helpfilepath := extractfilepath(application.exename) + 'help\WaterNET_user_manual.pdf';
DoesFileexists := False;
DoesFileexists := Fileexists(ExePath);
if DoesFileexists then
begin
{ Display Alert message that Adobe Reader 5.0 Required }
//GetVersion finds the version information using the file properties
AcroVersion := GetVersion(ExePath);
if StrToIntDef(AcroVersion,0) < 6 then
begin
MessageBox(Application.Handle,
pchar(#13 + 'Adobe Acrobat PDF Reader version6.0 (or newer) is required.'),
pchar('Adobe Reader Version'),
mb_OK + mb_ICONWARNING + MB_APPLMODAL);
exit;
end; //if StrToIntDef(AcroVersion,0)
// Checking that specified file is existing
if Not FileExists(HelpFilePath) then
begin
MessageDlg(MSG_HELP_FILE_NOT_EXIST, mtWarning, [mbOK], 0);
Exit;
end;
// set command line parameters based from where the help file is opened
case BookmarkConstant of
WNET_HELP_USER_MANNUAL :
// when user clicks on help->user mannual
begin
// '/s' used for silently opening the acrobat reader instead of the splash screen
CommandLine := ('/s /n /A page=1 "'+ helpfilepath +'"');
end;
help_WaterNET :
// when user clicks help-> WaterNET Help or press F1
begin
// '/n' used for openning the file in same opened acrobat reader
CommandLine := ('/s /n /A zoom="100"&page=1&pagemode=bookmarks "'+ helpfilepath +'"');
end;
else
// when user click help button on a dialog
begin
// using '/A' all the parameters consider as a string
CommandLine := ('/s /n /A page='+ inttostr(BookmarkConstant) + '&View=FitBV "'+ helpfilepath +'"');
end;
end;
IsAcroExeLocated := 0;
//executing the Acrobat.exe with command line parameters
IsAcroExeLocated := ShellExecute(0, {Forms handle}
'open', {Operation}
PAnsiChar(ExePath), {EXE name with path}
PAnsiChar(CommandLine), {Commandline parameters}
nil, {Working directory}
SW_SHOWMAXIMIZED); {show
state}
end;
// checking if Acrobat reader is not available then go for download the Acrobat
if not (DoesFileexists) or (IsAcroExeLocated < 32) then
begin
buttonSelected := MessageBox(Application.Handle,
pchar(#13 + 'No Adobe Acrobat PDF Reader found. Press OK to download Adobe Acrobat Reader or press Cancel to abort.'),
pchar('Adobe Reader Required'),
mb_OKCANCEL + mb_ICONWARNING + MB_APPLMODAL) = IDOK;
// checking if OK button is pressed then open the link for download the Acrobat
if buttonSelected then
begin
ShellExecute(0, {Forms handle}
'open', {Operation}
PAnsiChar('http://get.adobe.com/reader/'), {EXE path}
nil, {Commandline parameters}
nil, {Working directory}
SW_SHOWMAXIMIZED); {show state}
end;
end;
But I want to do all in VC++
|
|
|
|
|
deadlyabbas wrote: Actually I want to get the registry path where the .exe of Acrobat reader is.
FindExecutable() should do what you require.
"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
|
|
|
|
|
deadlyabbas wrote: ShellExecute(0,
"Open",
"%s\\HELP\\RiverCADPro_User_Manual.pdf",
NULL,
NULL,
SW_MAXIMIZE
question remain, do you want to load that in Adobe reader or in your application itself
"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
|
|
|
|
|
Please the questin attached to your reply ............
Yes I want to load the PDF and want to show the bookmarks also
|
|
|
|
|
Here is my code:
vector<int> CPanoCylinderImage::RGBofPixel(CImage image, int x, int y)
{
vector<int> vect;
COLORREF cr = image.GetPixel(x, y);
BYTE r = GetRValue(cr);
BYTE g = GetGValue(cr);
BYTE b = GetBValue(cr);
vect.push_back((int)r);
vect.push_back((int)g);
vect.push_back((int)b);
return vect;
}
float CPanoCylinderImage::IntensityOfPixel(CImage image, int x, int y)
{
vector<int> vect = RGBofPixel(image, x, y);
return 0.30f * vect.at(0) + 0.59f * vect.at(1) + 0.11f * vect.at(2);
}
float CPanoCylinderImage::LuminanceDifference(CImage image1, CImage image2, int length)
{
float diff = 0.0;
float sum = 0.0;
float intensity = 0.0;
vector<float> vectImage1, vectImage2;
for(int i = 0; i < image1.GetHeight(); i++)
{
for(int j = image1.GetWidth() - length; j < image1.GetWidth(); j++)
{
intensity = IntensityOfPixel(image1, j, i);
vectImage1.push_back(intensity);
}
}
return ;
}
image1 and image2 have been loaded correctly.When I calculate intensity first time, I got the right RGB value and intensity value. But second time, I got Debug Assertion Failed when it run statement "COLORREF cr = image.GetPixel(x, y);", messagebox told me that
File: ...........\atlimage.h
Line: 1217
Expression: hBitmap == m_hBitmap
Anybody know what's happening?
modified on Thursday, September 17, 2009 4:03 AM
|
|
|
|
|
Why don't you pass the CImage object by reference?
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]
|
|
|
|
|