|
Options in increasing order of complexity/robustness:
- Those mentioned, uncontrolled access by both apps/threads.
- LockFileEx() / UnlockFileEx() - OS level read/write locking, critical if multiple threads will be appending.
- Transactional NTFS - TxF API to perform transacted reads/writes, critical if multiple writes to different data sources (file, registry, database) may need to be rolled back and readers need consistant view across all.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Hi everyone,
I have an ActiveX control (or simply say a COM control) which was used within some applications so far.
As a new requirement this control should also be running within the browser.
So far so good, it works quite flawless.
But when a page including the control is opening, the bar for activating activeX is shown every time. This is not really great user experience if the prompting is done with every new browser session again and again.
Furthermore I have some cases where the current <object>-element is created at run-time. In this case the prompting is not done at all, the object is simply not initializing (except if you have allowed activeX within the same browser session before)
So my question is: Can I install my control in such a a way that IE allows showing it whout prompting? Maybe simply signing the DLL? Registering it as BHO? (All BHO-related stuff I found was gui-less, so it did not help me so far.)
How are plug-ins for IE developed usually? As I said, BHO offers no examples for content controls, maybe there is some NAPI-like interface for this? Has somebody usefull ideas how to develop a content control such as Flash that is simply installed and running in the browser without any prompting?
Thanks,
Roland
|
|
|
|
|
|
In a form, I am having a message map at the Tab-level like below:
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange)
From TabCtrl::OnDateTimeChange(), I have a call to next level DataFormDlg::OnDateTimeChange
TabCtrl::OnDateTimeChange
{
DataFormDlg->OnDateTimeChange;
}
Inside DataFormDlg, I have another message map as below
ON_NOTIFY_RANGE(DTN_DATETIMECHANGE, DLG_CTRLBASE, DLG_CTRLBASE + DLG_MAXITEMS_CTRL, OnDateTimeChange) and the function is
DataFormDlg::OnDateTimeChange ()
{
//body
}
Now when I click at the datepicker control, the DTN_DATETIMECHANGE event is triggering twice. So, the TabCtrl -> DataFormDlg -> OnDateTimeChange() is executing twice.
Could you please help me finding what is going wrong here?
Thanks,
modified on Wednesday, August 11, 2010 3:00 PM
|
|
|
|
|
Can I suggest you post this question to the correct forum, rather than this one, which doesn't cover MFC...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Thanks Stuart. I moved it to C / C++ / MFC. Hope that will help.
|
|
|
|
|
OK I found a sort algorithm on Wikipedia, that is done like the std::sort so I figured why not convert the who lot that I have to STL. Blah.
First the new sort
template<class ForwardIterator> void comb(ForwardIterator first, ForwardIterator last){
static const double shrink_factor = 1.247330950103979;
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type gap = std::distance(first, last);
bool swaps = true;
while ( (gap > 1) || (swaps == true) ){
if (gap > 1)
gap = static_cast<difference_type>(gap/shrink_factor);
swaps = false;
ForwardIterator itLeft(first);
ForwardIterator itRight(first); std::advance(itRight, gap);
for ( ; itRight!=last; ++itLeft, ++itRight ){
if ( (*itRight) < (*itLeft) ){
std::iter_swap(itLeft, itRight);
swaps = true;
}
}
}
}
So now the old bubble sort
template <typename T> void bubble(std::vector<T> &a) {
size_t size = a.size() - 1;
for (int pass = 0; pass < size; pass++) {
for (int n = 0; n < size; n++) {
if (a[n] > a[n+1])
std::swap(a[n], a[n+1]);
}
}
}
and this is as far as I have gone so far
template<class ForwardIterator> void bubble(ForwardIterator first, ForwardIterator last){
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_type;
difference_type size = std::distance(first, last);
}
http://www.contract-developer.tk
|
|
|
|
|
How's this?
template <typename T>
void bubble(std::vector<T> &a)
{
typedef typename std::vector<T>::iterator Iter;
Iter last = a.end()-1;
for(Iter pass=a.begin();pass!=last;++pass)
for(Iter n=a.begin();n!=last;++n)
if (*n > *(n+1))
std::iter_swap(n, n+1);
}
or this, which doesn't keep re-sorting the items at the end of the vector that have already been sorted…
template <typename T>
void bubble(std::vector<T> &a)
{
typedef typename std::vector<T>::iterator Iter;
for(Iter last = a.end()-1;last!=a.begin();--last)
for(Iter n=a.begin();n!=last;++n)
if (*n > *(n+1))
std::iter_swap(n, n+1);
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
After a few moments looking over the book I figured out that I need to watch the pointers close when using the STL method of iterators.
This is not well covered in any of the books I have. No big deal, that is what forums are for.
Here is what I ended up with that does work properly.
template <typename iterator> void bubble(iterator first, iterator last) {
iterator i, j;
for (i = first; i != last; ++i)
for (j = first; j < i; ++j)
if (*i < *j)
std::iter_swap(i, j);
}
Now I have this other sort that is annoying me.
template <class iterator> void gnome(iterator first, iterator last){
iterator pos = first;
iterator temp;
while (pos <= last) {
if ((pos == first) || (*pos >= *(pos-1)))
++pos;
else {
std::iter_swap(pos, pos-1);
--pos;
}
}
}
This one does not work, not sure what the problem is.
http://www.contract-developer.tk
|
|
|
|
|
What iterators are you calling it with?
This sample program seems to sort the data OK…
#include <vector>
#include <iostream>
#include <iterator>
template <class iterator> void gnome(iterator first, iterator last){
iterator pos = first;
iterator temp;
while (pos <= last) {
if ((pos == first) || (*pos >= *(pos-1)))
++pos;
else {
std::iter_swap(pos, pos-1);
--pos;
}
}
}
int main(int, char**)
{
std::vector<int> vec;
vec.push_back(4);
vec.push_back(3);
vec.push_back(5);
vec.push_back(-10);
vec.push_back(13);
vec.push_back(2);
vec.push_back(1);
gnome(vec.begin(), vec.end()-1);
std::copy(vec.begin(), vec.end(), std::ostream_iterator<int>(std::cout, " "));
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
here is the call routine
void RunGnomeSort(void) {
size_t size = 10000;
std::vector<int> data;
data.resize(size);
for (int i = 0; i < size; i++)
data[i] = (int)rand();
sort::gnome(data.begin(),data.end());
data.resize(0);
}
http://www.contract-developer.tk
|
|
|
|
|
Right - it's this line: sort::gnome(data.begin(),data.end());
Like in my example, that should be sort::gnome(data.begin(),data.end()-1);
data.end() points to the element after the last element in the vector, and the sort routine explicitly accesses the last parameter.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Then I guess I need to change the function a tad, so that its a drop in comparable to std::sort.
I changed the code
while (pos < last) {
from <=
That has it working now, thanks for spotting that. Now I think I will post the code on Wilipedia as the algorithm is not super clear.
http://www.contract-developer.tk
|
|
|
|
|
hello
On WM_MOUSELEAVE message the below function OnMouseLeave() is not getting called... (however OnInitDialog() is getting called)
I have created a dialog box and wanted to call my function OnMouseLeave() on WM_MOUSELEAVE message. Declared a message map as below,
BEGIN_MSG_MAP(CMyClass)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
END_MSG_MAP()
any idea if am missing something ?
Thanks and Regards,
Supriya Tonape
|
|
|
|
|
|
Just for completeness, the best place where you could put the TrackMouseEvent function, is inside the handler of the WM_MOUSEENTER message
|
|
|
|
|
Thank you. Yes I am using the trackmouseevent in OnMouseLeave() method.. actually i just replaced message as "WM_MOUSEMOVE" and it started working.. but thanks much for the help.
Also I cud not find WM_MOUSEENTER message in respective .h file..
thanks and regards,
Supriya Tonape
|
|
|
|
|
also I used TME_LEAVE to check mouse actions in trackmouseevent structure initialization.. in case if somebody faces the prob as I had..
|
|
|
|
|
How can my CDerivedEdit respond WM_SHOWWINDOW?
(OnShowWindow)just like MFC.
class CMouseValueEdit
: public CWindowImpl<cmousevalueedit, cedit="">
{
public:
DECLARE_WND_CLASS(_T("CMouseValueEdit"));
BEGIN_MSG_MAP_EX(CMouseValueEdit)
MESSAGE_HANDLER(WM_SHOWWINDOW, OnShowWindow)
MSG_WM_SHOWWINDOW(OnShowWindow)
//MESSAGE_HANDLER(WM_CTLCOLOREDIT, OnCtlColorEdit)
//MSG_WM_PAINT(OnPaint)
//MESSAGE_HANDLER(OCM_CTLCOLOREDIT, OnCtlColorEdit)
MSG_OCM_CTLCOLOREDIT(OnCtlColorEdit)
//REFLECTED_NOTIFY_CODE_HANDLER( WM_SHOWWINDOW, OnShowWindow)
DEFAULT_REFLECTION_HANDLER()
//CHAIN_MSG_MAP(CWindowImpl<cmousevalueedit, cedit="">)
END_MSG_MAP_EX()
CMouseValueEdit& operator=(HWND hWnd)
{
//m_hWnd = hWnd;
SubclassWindow(hWnd);
return *this;
}
}
class CMainDlg : public CDialogImpl<cmaindlg>, public CUpdateUI<cmaindlg>
, public CMessageFilter, public CIdleHandler
, public CWinDataExchange<cmaindlg>
{
public:
CMainDlg();
virtual ~CMainDlg();
CMouseValueEdit m_editMouse;
enum { IDD = IDD_MAINDLG };
BEGIN_DDX_MAP(CMainDlg)
DDX_CONTROL_HANDLE(IDC_EDIT_MOUSE, m_editMouse)
END_DDX_MAP();
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
return CWindow::IsDialogMessage(pMsg);
}
virtual BOOL OnIdle()
{
return FALSE;
}
BEGIN_UPDATE_UI_MAP(CMainDlg)
END_UPDATE_UI_MAP()
BEGIN_MSG_MAP_EX(CMainDlg)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
COMMAND_ID_HANDLER(IDOK, OnOK)
COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
REFLECT_NOTIFICATIONS()
END_MSG_MAP_EX()
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// center the dialog on the screen
CenterWindow();
//mp_editMouse->SubclassWindow(GetDlgItem(IDC_EDIT_MOUSE));
DoDataExchange();
// set icons
HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
SetIcon(hIcon, TRUE);
HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
SetIcon(hIconSmall, FALSE);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
UIAddChildWindowContainer(m_hWnd);
return TRUE;
}
}
OnShowWindow is not called.
I can't understand WTL...
|
|
|
|
|
Hi all ... I'm a 3rd year computer engineering student ... And i do have an idea but so far we learn how to make client-srever using " sockets " but the message queues is new method for me ... I'm required to do this project about how to develop authentication server that serves multiple clients at a time
the client gives the name and password as request and the server authenticates the request and returns the result ... ALL communications between client and server should use message queues techniques ...and i want it in c language ... Can u help me with the code ... appreciate it soo much ..
|
|
|
|
|
As a 3rd year student I am sure you understand the need to do your own research. We are not able to do your work for you but I will offer this link[^] to get you started. If and when you get a more specific problem then come back and ask for assistance.
It's time for a new signature.
|
|
|
|
|
ok thanx for the help .. appreciate it
|
|
|
|
|
Iam searching for one sample can any body help me out regarding this. I need to have 2 threads(Child Threads) acting on one ProgressBar(Main Thread) and have critical section Control on it for Syncronization. Please help me out regarding these.. or any sample... thanks in advance
|
|
|
|
|
If you are using the Windows ProgressBar[^] control then it is a simple matter of sending messages to the control to display what progress your application is making. No synchronisation is required except whatever is necessary between your threads.
It's time for a new signature.
|
|
|
|
|
Hi all,
Please let me know how to give the publisher name to my sample MFC application.
Currently it is displaying "Unknown" when i try to start it.
I am using Visual Studio 2008.
To see the publisher name -> Run an application as administrator in windows 7 machine and check the UAC dialog.
-Cvaji
|
|
|
|
|