|
Hi everybody!!!
Explain in what a difference of the next lines of a code on Win95:
1.
CRgn m_rgn1;
CRgn m_rgn2;
{
m_rgn1.DeleteObject();
m_rgn2.DeleteObject();
CRgn rgn;
rgn.CreateRectRgn (0, 0, 1, 1);
...
rgn.CopyRgn(*m_rgnToolTip);
...
rgn.CombineRgn (*rgn, *m_rgn2, RGN_OR);
SetWindowRgn (HRGN(rgn), FALSE);
rgn.DeleteObject ();
}
2.
CRgn m_rgn1;
CRgn m_rgn2;
{
m_rgn1.DeleteObject();
m_rgn2.DeleteObject();
CRgn rgn;
rgn.CreateRectRgn (0, 0, 1, 1);
...
rgn.CopyRgn(*m_rgnToolTip);
...
rgn.CombineRgn (*rgn, *m_rgn2, RGN_OR);
HRGN hRgn = CreateRectRgn(0, 0, 1, 1);
::CombineRgn(hRgn, (HRGN)rgn.GetSafeHandle(), NULL, RGN_COPY);
SetWindowRgn(hRgn, FALSE);
rgn.DeleteObject ();
}
Why on Win95 the first variant was fail
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Came across the following:
typedef double (*COMPLEX_ARRAY)[2];
What does this do??
Thanks for any help you might give me,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
pankajdaga wrote:
What does this do??
Confuse people, that's probably its main objective.
It's actually just a declaration for a pointer-to-a-two-dimensional-array-of-doubles-where-the-second-dimension-must-be-2.
So you can do this:
COMPLEX_ARRAY ca = NULL;
ca = new double[10][2];
delete [] ca;
double xyz[5][2];
ca = xyz;
ca[0][0] = 4.6;
ca[0][1] = 20.67;
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Ahhhhhh... I see. I knew it was like that. The syntax just confused the hell out of me. Thanks for the explanation! I wonder why people code like that!
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Multi-dimensional arrays in C/C++ make C strings look like the greatest thing since sliced bread.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi. Im thinking of using crystal reports in my companys applications but im not sure how the licensing works.
The main question is: if i dont require the clients aplication to have a report designer, only print preview, printing and exporting, which license must i purchase?
I dont think i need the "Crystal Reports 9 Report Creation API Named User License, English", cause it includes the designer "...in order to integrate end user report creation capabilities into thick-client desktop applications.".
But i havent found another licensing program for my case.
Anyone with experience in this can help me?
|
|
|
|
|
Miguel Lopes wrote:
Anyone with experience in this can help me?
When I used Crystal 8.5 we had to make sure that we had a license for each client even though all they were doing was viewing the report (ad-hoc). We looked into using them for reporting over the web; however we decided to go with Data Dynamics because they have a royalty-free report designer. Besides, Crystal Reports over the web is way too expense, call them and they will quote you a price.
Nick Parker
The only man who never makes a mistake is the man who never does anything. - Theodore Roosevelt
|
|
|
|
|
Hi. Thanks for the quick answer.
I started looking at Data Dynamics for their "Active Reports" products, but it seems it only works with VB! Im a VC++ programmer and im in a middle of a vc++ software development, so vb is not an option.
On the other hand, it has an activeX version... can i access it easely through vc++?
|
|
|
|
|
Miguel Lopes wrote:
On the other hand, it has an activeX version... can i access it easely through vc++?
With version 8.5 you most certainly can, you used to be able to download a free trial version which actually came with samples in the different languages, I remember it had samples for both VB and VC++. Check them out, they really have a nice product, but so does Crystal. I think it really depends on how much you are willing to pay. I haven't found anything that I couldn't do with Active Reports that I could with Crystal.
-Nick
|
|
|
|
|
You were right! Active Reports is really an excellent product! Ive read most of their documentation and it fits really well! Now im stuck cause i dont find VC++ samples and especially cause i dont know how can i get the required DLL's to make a test application so we can decide to buy it or not.
Can u give me some links or hints?
Thanks for the help in general!
|
|
|
|
|
Miguel Lopes wrote:
Can u give me some links or hints?
Try Product Downloads[^], select ActiveReports 2.0 Pro unless you need to get the .NET version. I believe that it comes packed with samples. Let me know.
-Nick Parker
|
|
|
|
|
Thanks for the quick answer! Since my last msg, i already started to use the product downloads and right now i already have a vc++ working app with the activeX. Now i only need to learn the API
Thanks for the help! Now im on track. Ill have it incorporated in our apps within a week!
|
|
|
|
|
Glad to help.
-Nick Parker
|
|
|
|
|
I have a window which contains a bunch of checkboxes and buttons. They need to be created dynamically based on the output of a parsed configuration file. The controls will, after creation, have their font set to DEFAULT_GUI_FONT. Given that the labels in the controls are arbitrary, I need a way to determine the necessary size of the buttons. It must be pretty close to minimum size to give proper visual layout: it would be bad aesthetics to leave a bunch of excess margin on the right to account for potentially longer labels than anticipated. Same goes for the height, I don't want excess margin between the buttons. Keeping the right and between margins to a minimum will minimize the wasted screen real estate as well, which is fairly critical for this application. So how does one determine the necessary size? I could just get the text extents from the font, but then I'd have to hardcode the added sizes like the label-to-frame margin within the buttons and size of the non-label portion of a checkbox, but that seems kludgy. Is there an API to, after setting the font of a control, tell it to resize itself to the proper minimum dimensions? I can't find one but hope it's buried in there somewhere....
Thanks in advance,
Brian Tietz
|
|
|
|
|
I think you have to do it the hard way... and it doesnt seem so difficult...
May the SOURCE be with you
|
|
|
|
|
By "the hard way" do you mean kludging in extra pixels relative to the text extents?
|
|
|
|
|
Yes, and it doesnt sound so devlish as you put it. Remember that engineering is not allways a precise field, and sometimes all a gadget needs is a small kick or slap "adjustment". And even if you found that API, it would probably do it this way.
|
|
|
|
|
I have an application with a system wide hook in a DLL. I hook on WH_SHELL, and within the hook process a message is sent back to the application. I do the following:
Inside DLL
const UINT wm_Snd =RegisterWindowMessage( "TEST_MSG" ); //global variable
inside the hook routine:
PostMessage(HWND_BROADCAST,wm_InternetCheck,0,0);
Now inside my CMainframe application:
header:
afx_msg LRESULT OnTest(WPARAM wParam, LPARAM lParam);
source code:
const UINT mw_Snd = RegisterWindowMessage( "TEST_MSG" );//global variable
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG(CMainFrame)
//}}AFX_MSG
ON_REGISTERED_MESSAGE(mw_Snd ,OnTest)
DECLARE_MESSAGE_MAP()
}
LRESULT CMainFrame::OnTest(WPARAM wParam, LPARAM lParam)
{
AfxMessageBox("Called..");
return 0;
}
Now in debug mode, It works no problem. But In Release mode, the message doesnt get to the application. It gets posted okay from the DLL, but the
AfxMessageBox("Called.."); Never gets called.
Neil
|
|
|
|
|
I have made a program using MFC wizard to make a dialog box. I need to add a "Browse" button through which the user can select one file or folder, and get the filename and path (relative to the program's folder, assuming that the file or folder is in it, or the full path if outside the program's folder). I then want to put that name and path into an edit box in 8.3 filename format. Is there a simple way to do such a thing?
Thank you very much for your time and effort.
<marquee>Hosam Aly Mahmoud
|
|
|
|
|
Yes. One solution is CFileDialog.
Kuphryn
|
|
|
|
|
I think you should take a look at the CFileDialog class in the MSDN for using the "open file" common dialog.
CFileDialog
The paths retreived from the CFileDialog s are all absolute path, so you need to change it to relative paths yourself.
I did not try to get folder paths using this common dialog but you may use the "Browse For Folder" dialog that can be used through the SHBrowseForFolder() shell function. Again you will find it in the MSDN.
SHBrowseForFolder()
This function could be a little complicated to use but I think there are some wrapper classes on code project for it.
For the last part cocerning the 8.3 paths there is the API function GetShortPathName( ) for doing this and here is its parameters.
DWORD GetShortPathName(
LPCTSTR lpszLongPath,
LPTSTR lpszShortPath,
DWORD cchBuffer
);
|
|
|
|
|
Thank you very much for your help.
1. I couldn't understand how the shell function SHBrowseForFolder() works. Could you please tell me either how to use it or how to avoid it?
2. Is there a way to find the path of the program? This way I could remove it from the path to get a relative one.
3. How can I use an API function inside my MFC application?
Thank you again.
<marquee>Hosam Aly Mahmoud
|
|
|
|
|
1. As i told you in my post you could find a wrapper class for the SHBrowseForFolder( ) on code project this is its link http://www.codeproject.com/shell/cxsbrowsefolder.asp
2. The best way to get the program path exactly is to use the function GetModuleFileName() this is its declaration:
DWORD GetModuleFileName(<br />
HMODULE hModule,
LPTSTR lpFilename,
DWORD nSize
);
This function gives you the whole path to your program including the file name. Just remove the file name and you get theabsolute path of the program.
This is an example of how to use it to get the program path:
TCHAR procPath[MAX_PATH];
GetModuleFileName(hInst, procPath, MAX_PATH * sizeof(TCHAR));
CString strPath = procPath;
strPath = strPath.Left(str.ReverseFind('\\'));
But in some cases this is not the working path of the program (i.e. the working path is the path assumed if you just gave the program a file name only). One of this case is if you tried to double click a document to be opened with your program , in this case the working path will be that of the document. Any way to get the working path you may use the funcion GetCurrentDirectory()
DWORD GetCurrentDirectory(<br />
DWORD nBufferLength,
LPTSTR lpBuffer
);
it returns the current working directory of the program. See which one suits your situation and use it.
3. MFC are wrappers for the API functoins, you can call API functions anywhere in your MFC project as any other function, but in some cases an MFC method could have the same name as an API in this case you should preceed the function call with a double scope.
e.g. the method SetWindowText() if you want to call the API SetWindowText() instead of it call it like that
::SetWindowText()
|
|
|
|
|
Thank you very much for your appreciated help.
Now I want to remove the path from the filename I got from the Browse button. I shall tell you of a way I tried to use (before I read your second reply).
I used system ( "cd >> dir" ) to get the program's path, read it in a buffer and then compared it to the first characters in the filename. To take out the path, here is the code I used:
for (short i = 0; i < length; i ++)
if ( FileName.GetAt(i) != path.GetAt(i) ) { i=-1; break; }
if (i == -1) break;
for (short j = 0; i <= FileName.GetLength(); i ++, j++)
FileName.SetAt (j, FileName.GetAt(i) );
This part of code was inside a loop, and length is the length of the path of the program. FileName is the buffer in which I stored the filename from the browse button. The problem with the above code is that it doesn't work when the program is at the root folder of a partition. What do you think is the reason?
I am thinking of using a similar code (with GetModuleFileName instead of system ( "cd >> dir" ) . But shouldn't this give me the same problem?
If you find that my method was faulty somehow, please tell me.
Again thank you for your help.
<marquee>Hosam Aly Mahmoud
|
|
|
|
|
Let's say I have a some user mode C code, and I want to execute some privilged instruction, like wrmsr.
I write a function in user mode called mywrmsr( ARGS args ); with a bunch of instructions that can't be executed in user mode.
Then I send the address of this function (and the args) to a kernel driver with an IOCTL.
The kernel driver executes the code given by the function *.
Will this work???
Jeff Yunes
Georgia Institute of Technology
Intel Corporation
|
|
|
|