|
If you want to use integer arithmetic without floating point then do it this way:
unsigned __int64 size = 524285686;
const unsigned MEG = 1024*1024;
unsigned megs = (unsigned)(size / MEG);
unsigned fraction = (unsigned)((size % MEG) * 100u / MEG);
printf("%u.%02u\n", megs, fraction);
EDIT: changed from signed integers to unsigned integers
modified 18-Sep-13 6:15am.
|
|
|
|
|
Hello all,
I want to develop a DLL that has a web browser embedded in it. In the past i have created MFC dialog app using CDHtmlDialog. With that experience what i want to achieve is create a DLL that has browser embedded in it, and then load this DLL into a web browser like IE, Chrome or Firefox.
I want all the GUI elements to be developed in HTML with some JavaScript(JS) added. Now i want to trigger the controls in the HTML/JS using the C++ code that runs the DLL. And also i should be able to launch this DLL on another web browser and display the HTML/JS controls.
Is this possible to do?
The reason why i want it this way is because the C++ code in the DLL will talk with another C++ DLL and take instructions on how and when to show the HTML/JS controls.
As i said earlier, i have worked with CDHtmlDialog in MFC Dialog app. But in this case i don't need any MFC controls. All i need is a Web Browser capability like the one CDHtmlDialog provided. And also this should be launchable from with in another web browser like IE or Chrome or Firefox.
Please let me know of any examples that does similar things.
Thanks in advance.
|
|
|
|
|
Don Guy wrote: Is this possible to do?
I suppose anything is possible, but what is your specific question?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Don Guy wrote: Please let me know of any examples that does similar things. Google is the place for such questions. Also it is not clear exactly what your problem is.
Veni, vidi, abiit domum
|
|
|
|
|
Ok let me be more specific here:
Is it possible to create a C++ DLL with WebBrowser embedded in it?
I am using Visual Studio 2012.
|
|
|
|
|
Yes, it's possible. Now, do you have an actual question?
Veni, vidi, abiit domum
|
|
|
|
|
How to do that? Any sample project to help?
|
|
|
|
|
Your question is too broad for a technical forum; we deal here with specific problems. For general "how to" questions you need to do the research and find the samples and articles that will help to build your project.
Veni, vidi, abiit domum
|
|
|
|
|
Lemme rephrase the question
Is it possible to add/embedd CDHtmlDialog inside a Win32 DLL?
|
|
|
|
|
How many times do you plan to repeat this question? Yes it's possible, but you are the one who is going to have to write the code to make it happen.
Veni, vidi, abiit domum
|
|
|
|
|
Don Guy wrote: I want to develop a DLL that has a web browser embedded in it. ...then load this
DLL into a web browser like IE, Chrome or Firefox.
So you have a web browser (doesn't matter whether you create it or not) and then run it in a web browser.
Why?
The question is similar to asking if one would want to run Chrome inside of Firefox.
Don Guy wrote: Is this possible to do?
It is possible to create a web browser in a dll. To create a functioning browser then one would simply use the dll in the exe and call probably one method.
That said a web browser is a user tool and a client side tool. I doubt there is any need to have a browser that one can embed and moreover it would likely irritate users because a non-trivial number of them are really attached to the browser they use.
Standard browsers can run executable content if the users allow that. The executable content can be anything, so it could certainly start a browser.
But excluding attempts to circumvent security and attempt to hack information from users I can't see any point to this.
|
|
|
|
|
I am unable to set focus to CProperyPage CEdit control using OnSetActive:
BOOL C_CommPropertyPage2::OnSetActive()
{
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
pBoxOne->SetFocus();
return CPropertyPage::OnSetActive(); // added
}
I am able to TAB to the controls and I have tried both value and control without success.
Any help would be appreciated.
Cheers Vaclav
Here is a workaround.
I initially fill the edit boxes with default values. When I reset them, in my case to empty text, I can set focus using the above code. I can live with that.
-- modified 17-Sep-13 13:34pm.
|
|
|
|
|
Have you tried putting
return CPropertyPage::OnSetActive();
as the last line in the handler?
|
|
|
|
|
Yes, sorry I did not included it in the snippet.
|
|
|
|
|
Is the edit control the first control on that tab (that the user can interact with)?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Yes, but it fails to set focus to any. I currently have four.
|
|
|
|
|
Vaclav_Sal wrote: Yes... So the z-order is set correctly?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I can TAB thru all four edit boxes in sequence, in circular fashion. If that is what you are asking.
|
|
|
|
|
How can I write Outlook addin which support all versions of Outlook?
|
|
|
|
|
|
i can lock a thread, but how about single function?
int Func(int par)
just want to lock it so other function do not call it until it finish, is that possible?
|
|
|
|
|
What do you mean by "lock a function"? By definition you can only lock it if it is running in a separate thread.
Veni, vidi, abiit domum
|
|
|
|
|
|
If you want something inside the function protected from parallel/recursive calls, you can do that by placing a criitical section and a class member variable inside it. If don't want the function to be called at all, you could make it private and add a public function as the only one that calls it. It could look something like that:
void somePublicFunc()
{
EnterCriticalSection(); try
{
if (!alreadyRunning) {
alreadyRunning = true;
privateFunction();
alreadyRunning = false;
}
}
catch (...)
{
alreadyRunning = false; LeaveCriticalSection(); throw; }
LeaveCriticalSection();
}
So privateFunction() will only be called once at a time no matter from which thread (provided you don't add another member function that calls it or introduce any friend classes).
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
Not bad but in C++ you should use RAII for this, use the destructor of an auto (stack) object as your finally block.
class CAutoLock
{
public:
CAutoLock(CRITICAL_SECTION& cs)
: m_CS(cs)
{
EnterCriticalSection(&cs);
}
~CAutoLock()
{
LeaveCriticalSection(&m_CS);
}
private:
CRITICAL_SECTION& m_CS;
};
void func()
{
CAutoLock auto_lock(cs);
{
CAutoLock auto_lock2(cs2);
}
}
|
|
|
|