|
i'm not so familar with wtl - but it sounds cause the IsDialogMessage() function is callin' twice.
override the TranslateAccelerator function to set the focus by your own. because windows cannot (will) set focus among nested dialogs. but i'm not shure if there isn't a possibility to do that on another way.
|
|
|
|
|
I'll look into that; thank you!
D.T. Doutel
|
|
|
|
|
Hi,
Your message loop must call PropSheet_IsDialogMessage() when the PropSheet is not modal.
For instance in a parent frame deriving from WTL::CMessageFilter :
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
return CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg) ? TRUE :
PropSheet_IsDialogMessage(<My Property Sheet member>.m_hWnd, pMsg);
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Friday, December 10, 2010 5:07 AM
|
|
|
|
|
I have this :
struct struct_X
{
struct_X() :
nX(0)
{
}
int nX;
CString m_strName;
};
struct_X *ptrX1=NULL;
struct_X *ptrX2=NULL;
i have a loop like this :
for(int Idx = 0; Condition; Idx++)
{
...
...
if(nCount==0)
ptrX1= new struct_X;
else
ptrX1=ReallocArray((nCount+1), nCount, ptrX2); // copy the content of ptrX2 to ptrX1 and delete ptrX2 (**)
if(ptrTmp==NULL)
break;
ptrX2=ptrX1;
ptrX2[nCount].nX = 1;
ptrX2[nCount].m_strName = strTempName; // Here I have an a crash related to CString acces violating
nCount++;
}
in the first loop ( nCount = 0) there is no problem
but after the ReallocArray (**) i get the problem in ptrX2[nCount].m_strName
Have any one idea how to solve this?
|
|
|
|
|
Hi,
Looks like a problem with your ReallocArray() .
ATL::CString and MFC CString are simply typedef ATL::CStringT<TCHAR> CString; so at first your code may be crashing because of a wrong TCHAR type.
Anyhow you should always use the CString copy operator and not try to manipulate internal data structures as you do.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
ReallocArray()
just get the ptrX2 and copy its elements to the new array ptrX1 which has number of ptrX2's elements + 1
and then delete ptrX2.
So I think the problem is no related to this.
I agree that there is problem somewhere in CString opreation but where
|
|
|
|
|
khaliloenit wrote: ReallocArray()
just get the ptrX2 and copy its elements to the new array ptrX1 which has number of ptrX2's elements + 1
and then delete ptrX2.
And when do you construct your new struct_X ?
Drop your dangerous and painful homecooked memory management for ATL::CSimpleArray<struct_X> or std::vector<struct_X> and your problem will disappear
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
1.) c!=c++
2.) c++ has a destructor and constructor that initializes the vtable too.
3.) c++ has not a realloc it knows only new and delete (its a immanent failure of c++)
4.) if you realloc an array of classes and they have virtual functions (ie. virtual void doanything(); ) you MUST call the constructor by yourself (and the destructor too).
5.) how to do: for(i=last_valid_element+1;i<all_elements;i++) (ptrX2+i)->struct_X::struct_X();
5a) remember: struct is in c++ the same as class.
6.) destructor for all elements or delete [] ptrX2 ( calls implicit (ptrX2+i)->struct_X::~struct_X(); )
so far and nice day.
|
|
|
|
|
Hi All,
I want a C programme which will take a user input as a date and number of days,
and then it will add the given number of days to the input date and will give the resulted date.
It should keep in mind all the permutation and combinations like changing month year , leap year, some months have 31 days some have 30 days etc....
for eg.:
input date 2010-12-25
days 20
result 2011-01-14
This programme can be made but this will take a lot of time if anybody has similar to that or exact programme then please help....
its just a module.
Thanks
|
|
|
|
|
cmaheshwari16 wrote: I want a C programme which will take a user input as a date and number of days,
A simple search of your C reference or MSDN would have found these routines[^] for you.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Sir
Thanks for your reply
I am working on linux....
and the link you have given...
I dont find any function which can add some day to the particular date to give new date.
Thanks
|
|
|
|
|
cmaheshwari16 wrote: I dont find any function which can add some day to the particular date to give new date.
Convert your date to a time_t or a struct tm [^] and some simple mathematics will allow you to calculate your results.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Thanks Richard.....
But I was expecting some live example to get the clear understanding...
Its now done by using the below way
just creating the object of struct tm
and then giving the values to the variables of the structure
adding the days to the tm_mday variable
using the mktime() function, converting it back to a structure.....
and then accessing the required values with the structure variable...
I still want to understand the use of the time_t.......if u can......
|
|
|
|
|
What you describe above sounds fine. The time_t type is just a value that represents the current time and date as calculated by the OS that you are running on (i.e. Windows, Linux, AIX etc). The struct tm is created by breaking a time_t value into its constituent parts to allow for the type of calculation that you are doing. If you go to the link I gave you for struct tm and look at the menu in the botttom left pane you will see listed all the various time routines, take a look at each of them to see some sample code.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi Richard,
Now its more clear......
Thanks
|
|
|
|
|
You're welcome.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hello,
I need to read all GUIDS defined inside abcdef_i.c(where abcdef can be any file defining all guids of a COM component) file from DIA SDK?
I need to extract all relavent component's Guids defined under COM component from pdb file. I am using DIA SDK, but always its get_guid returns badPtr(0x000) and it is reported bug of MSFT
Regards
Usman
|
|
|
|
|
why can i code like this:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
template <class T>
void OUT(T c)
{
cout << "!!" << c ;
}
int main()
{
vector<string> st(10, " ");
for_each(st.begin(), st.end(), OUT);
}
i know information about for_each :
/*template <class InputIterator, class Function>
Function for_each (InputIterator first, InputIterator last, Function f);
Apply function to range
Applies function f to each of the elements in the range [first,last).*/
but why they don't use Function Templates instead of function, thank you
|
|
|
|
|
Not sure to answer your question as it is formatted but f can either be a pointer to a function or an object whose class overloads operator()(InputIterator::value_type) .
See http://www.cplusplus.com/reference/algorithm/for_each/[^]
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
This is called 'generic' programming. The term 'generic' means that the definition of the for_each function does not assume anything else from the template argument than that it has an operator()( T ) .
If they would have implemented it using a function pointer,
# they would have needed to specify the function pointer's type (e.g. void (*) (int)) and thus would have disallowed any other type of function (remember C)
# they would have disallowed the use of stateful functions (e.g. accumulators), like often needed for the algorithms
Also, the usage of templates greatly improves the optimizer's chances: it knows _at compile time_ what the body of the for_each block is going to be, so it can often skip parameter pushing etc..., hence reducing function call overhead.
|
|
|
|
|
I have been working on a project for the last year and I have make much progress but much remains. First I will provide headers of what I have done so far.
template <class T> class vector;
template <class T> class matrix;
template <typename T> T norm(vector<T> v);
template <typename T> T norm(matrix<T> m);
template <typename T> void transpose(matrix<T> &m);
template <typename T> void conjugate_transpose(matrix<T> &m);
template <typename T> bool hermetian(matrix<T> &a, matrix<T> &b);
template <typename T> matrix<T> tensor_product(vector<T> row, vector<T> col);
template <typename T> matrix<T> minor(matrix<T> &source, int row, int col);
template <typename T> bool diagonal_dominant(matrix<T> a);
template <typename T> matrix<T> gauss_elimination(matrix<T> &m);
template <typename T> matrix<T> gauss_jordan(matrix<T> &m);
template <typename T> void gauss_siedel(matrix<T> a, vector<T> b, vector<T> x, double tolerance);
Now I can use vector<std::complex> and use it with math equations fine. Same for the matrix template.
So given my work to make these helpful templates, I am now out of my math book big time and into the realm of advanced linear algebra.
This is my Gauss elimination, and I was looking to leverage it to do LU decomposition etc to solve Ax = b more expediently.
template <typename T> matrix<T> gauss_elimination(matrix<T> &mat) {
int i = 0; int j = 0; int maxi;
matrix<T> a = mat;
int m = (int)a.size();
int n = (int)a[0].size();
while ((i < m) && (j < n)) {
maxi = i;
for (int k = i + 1; k < m; k++)
if (std::abs(a[k][j]) > std::abs(a[maxi][j])) maxi = k;
if (a[maxi][j] != 0) {
swap(a[i], a[maxi]);
a[i] = a[i] / a[i][j];
for (int u = i + 1; u < m; u++)
a[u] = a[u] - (a[i] * a[u][j]);
i++;
}
j++;
}
return a;
}
Suggestions?
http://www.contract-developer.tk
|
|
|
|
|
|
Hi to all.
How can I change( set) the active tab in Tabbed MDI app created using VS2008. I need to set active tab from CMainFrame using zero based index (what I need is a pointer to CMFC(Base)TabCtrl so I can call 'SetActiveTab(int id)' )?
Thanks in advance
|
|
|
|
|
HI!
I get a jpg picture control like this:
typedef CMapViewCtrlImplTraits<WS_TABSTOP | WS_GROUP | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_HSCROLL | WS_VSCROLL, WS_EX_CONTROLPARENT> CMapViewCtrlTraits;
template <class T, class TBase = CStatic, class TWinTraits = CMapViewCtrlTraits>
class ATL_NO_VTABLE CMapViewCtrlImpl : public CWindowImpl<T,TBase,TWinTraits>,
public CScrollImpl<T>
{
public:
DECLARE_WND_SUPERCLASS(NULL,TBase::GetWndClassName())
typedef CMapViewCtrlImpl< T, TBase, TWinTraits > thisClass;
}
Problem is when I load a jpg file,the control have rightscroll ,but the message WM_VSCROLL can't be send.
The scroll just visible,it can't do anything.
Why?
|
|
|
|
|
Hi,
See the CBitmapView class in <WTL>\Samples\BmpView\view.h, you may probably use it as-is.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|