|
|
What?!
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have added dual interfaces to an existing class in MFC application but when i run the client the cocreateinstance is failing with the error 0x80080005 (CO_E_SERVER_EXEC_FAILURE) Server execution failed. I had followed the steps from the articles below:-
http://www.codeproject.com/Articles/8202/Adding-automation-to-MFC-applications.
https://msdn.microsoft.com/en-us/library/4h56szat.aspx[^]
Hide Copy Code
hr = ::CoCreateInstance(CLSID_Application, NULL, CLSCTX_LOCAL_SERVER, IID_IApplication, (void**)&m_IApplication);
if (SUCCEEDED(hr)) {
if (m_IApplication)
{
m_IApplication->Show();
}
}
|
|
|
|
|
Check the even log for the details.
|
|
|
|
|
As topic says, I'm having some HItTest issue.
Background:
I'm making a windows mobile ce 6.5 application.
There is some resource based dialog with ListView on it.
I'm subclassing the ListView with "CustomLVCtrl" and HeaderCtrl with "CustomHCtrl".
Both custom controls have increased height based on some constant value.
Now about my problem:
From WM_GESTURE GID_HOLD handler i'm getting some screen coordinates and then testing if any ListView item is being hold.
The problem is that i'm never getting a valid item index. It looks like item with index 0 is under the header, because testing first item results in 1, second returns 2, ..., then last returns -1. These results are not accurate for the whole item height either.
Simplified code:
void Controller::onHold(int x, int y)
{
CPoint point(x, y);
view_->list_.ScreenToClient(&point);
LONG dlgBaseUnits = GetDialogBaseUnits();
int baseunitX = LOWORD(dlgBaseUnits), baseunitY = HIWORD(dlgBaseUnits);
point.x = ATL::MulDiv(point.x, 4, baseunitX);
point.y = ATL::MulDiv(point.y, 8, baseunitY);
LVHITTESTINFO lvhti;
lvhti.flags = 0;
lvhti.pt = point;
int nItem = view_->list_.HitTest(&lvhti);
if (lvhti.flags & LVHT_ONITEM)
{
ShowModal(nItem);
}
}
I've also tried with
RECT rect={0,0,4,8};
MapDialogRect(hwnd, &rect);
int baseunitX = rect.right;
int baseunitY = rect.bottom;
point.x = ATL::MulDiv(point.x, 4, baseunitX);
point.y = ATL::MulDiv(point.y, 8, baseunitY);
but with same results. Can anyone point out what I'm doing wrong?
|
|
|
|
|
Visual Studio 2008, C++, MFC
lang="cs">
const char build_date[] = __DATE__;
swprintf_s( my_date, my_size, L"%s", build_date );
swprintf_s( my_date, my_size, L"%ls, build_date );
show_date.SetWindowTextW( my_date );
show_date.SetWindowText( __DATE__
show_date.SetWindowText( L"this displays" );
String my_date does not contain the date that is found in build_date. Multiple versions have been tried and not successful in getting compile date to display in the dialog. All the searches I have done tell me this should work.
What must be changed?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 24-Apr-15 8:02am.
|
|
|
|
|
You are using the wide character version of swprintf_s , but your date string is char type, so you need to use the upper case S in your format string so it gets converted to Unicode, thus:
swprintf_s( my_date, my_size, L"%S", build_date );
|
|
|
|
|
That was it. Thank you.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
This application has several pointers to be deleted in the destructor. Each is logged when created and again when deleted to reduce the possibility of an undetected memory leak. As there are several, a function is needed to do the deletes. The goal is to avoid writing all that logging code multiple times. Below is the concept. The first time it was tried the subject was an instance of a class with its own destructor. A breakpoint was placed in that destructor.
Void Delete_Stuff( WCHAR * name, void * item )
{
If( item != NULL )
{
Write_Log_Entry( L"Preparing to delete <name> at address <*item>"); // please see note
delete ( item ); // does not call the destructor
delete ( *item ); // illegal indirection
}
}
EDIT: I wrote the text up in MS word and did not notice that the leading character of "delete" had been capitalized. Apologies for that.
Note: An swprintf_s(…) is used to build the string and the named function does the logging. Please accept the gross simplification used to make the main point obvious.
The destructor for the object is not called. I have tried a few combinations including * *. I managed to corrupt the heap at least once. Can this be fixed and work as desired or must each item be deleted one at a time without using the Delete_Stuff( … ) function.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 24-Apr-15 8:02am.
|
|
|
|
|
|
It stepped through the delete but the destructor for that class/object was not called.
Note: I wrote the text up in MS word and did not notice that the leading character of "delete" had been capitalized. Apologies for that.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
OK, but what is your Delete method actually doing?
|
|
|
|
|
I do not have a delete function. The parens were used in an attempt to tell the standard delete operation that I want to delete the object pointed to by the pointer. An indirect delete rather than a direct delete.
class widget{ ... }
p_widget = new widget;
...
delete_stuff( L"widget", p_widget );
...
void delete_stuff( WCHAR * name, void * item )
{
delete *item;
... logging code not shown.
}
The destructor of widget has a breakpoint that was never hit. I presume that widget was not deleted.
Because that did not work, I tried dereferencing and grouping the pointer as in:
delete *item;
and
delete (*item);
I am unable to get the breakpoint in the destructor so presume I am doing something wrong.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 22-Apr-15 15:25pm.
|
|
|
|
|
I see the problem; my bad for missing it in your original question. Your function has the signature:
Void Delete_Stuff( WCHAR * name, void * item )
so when you call delete item the compiler has no idea what type item is, so just throws it away. You can only call delete on an object, when it is specifically typed so the compiler knows how to deal with it. You may try casting it to the relevant class type, but you would need some way of telling your function what type each pointer is.
|
|
|
|
|
Then I cannot do that. Ok. thanks for taking the time to explain.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|
|
See my better explanation below.
|
|
|
|
|
This is how it needs to be done:
class Object
{
public:
Object()
{
cout << "Object constructor" << endl;
};
virtual ~Object()
{
cout << "Object destructor" << endl;
};
};
class Widget : Object
{
public:
Widget()
{
cout << "Widget constructor" << endl;
};
~Widget()
{
cout << "Widget destructor" << endl;
};
};
static void Delete_Stuff(char* name, Object* object)
{
cout << "cleanup " << name << endl;
delete object;
}
|
|
|
|
|
I looking so hard how to make my simple window form application to <always on="" top=""> like Task manager (include start screen).
Some reference :
- Form Stackoverflow
- Form Blogs microsoft
As of these reference i try but it not work,anyone have any idea?
Please help me !
Thank you in advance !
|
|
|
|
|
Properties -> Window Style -> TopMost: True = always on top.
|
|
|
|
|
The property TopMost: true is work only for classic app but for metro app & start screen still not work !!
|
|
|
|
|
Rainsey Long wrote: metro app I suggest you try the proper forum for metro questions.
|
|
|
|
|
Windows XP, soo not be Win 7, Visual Studio 2008, C++
Every build proclaims that WINVER is not defined, setting to 0x600 Windows Vista. This is on Windows XP so I don't understand why it is setting to Vista.
Where should it be set?
stdafx has the lines:
#ifndef WINVER
#define WINVER 0x0400 // this line grayed out
#endif
That indicates it is already set, but the output window says not.
I put this definition in the first include file AR2_Message_AppDlg.cpp
#define WINVER 0X0601
but it appears to be ignored. An MSDN web page said to put it in "a header file." It does not say which one.
Where should the definition be placed?
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
modified 24-Apr-15 8:03am.
|
|
|
|
|
The Windows version is set from the SDK header files, so it does not necessarily match the actual level of Windows that you are developing on. You can set it to your own target in your main header file, before your include of windows.h; if using precompiled headers then that would be your version of stdafx.h.
|
|
|
|
|
With visual studio "find in files", you can find all #define WINVER when look in "visual c++ include directories"
I get: winres.h, sdkddkver.h, vdssys.idl, WinDef.h, WinGDI.h, WinReg.h, WinResrc.h, winsdkver.h and WinUser.h
But you have to start follow the includes in your stdafx.h
to find the ones your application is including.
I see:
#include "targetver.h"
which includes
#include <SDKDDKVer.h>
which is one on my list and contains
#ifndef WINVER
#ifdef _WIN32_WINNT
#define WINVER _WIN32_WINNT
#else
#define WINVER 0x0601
#endif
#endif
So if you put in stdafx.h
#ifndef WINVER
#define WINVER 0x0400
#endif
before
#include "targetver.h"
then it is not grey out.
modified 2-Apr-15 6:58am.
|
|
|
|
|
Ok, I am using that now, in stdafx.h
Thank you for your time.
Thank you for your time
If you work with telemetry, please check this bulletin board: www.irigbb.com
|
|
|
|