|
I am currently using ON_WM_HSCROLL.
Can you direct me to the message handler functions for TB_THUMBPOSITION
|
|
|
|
|
SB_THUMBPOSITION is a possible value passed in the low word of the wParam parameter of the WM_HSCROLL message. In MFC it is the nSBCode parameter of the OnHScroll handler.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Suppose i have a set up like this:
class Base
{
public:
int x;
virtual void f()
};
class Derv:public Base
{
public:
int y;
void f();
};
void main()
{
Base *p;
p=new Derv[4];
for(int i=0;i<4;i++)
(p+i)->y=10;
delete[]p;
}
NOW HERE IS THE PROBLEM-
I can access the first element using pointer 'p' BUT if i try to acces the second element of the array by doing p+1, MY PROGRAM CRASHES...
This is the problem:
Suppose the derived class array was allocated at 0x00000000, then p contains 0x11111111. I thought that p+1 will be 0x11111111+sizeof(Derv), BUT it is 0x11111111+sizeof(Base)
SO WHAT I WANT TO KNOW FORM YOU FRIENDS IS - HOW TO ACCESS THE ELEMENTS OF A DERIVED CLASS ARRAY USING BASE CLASS POINTER ???
thanx for ur time
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
Hey Avenger,
Here's a funny workaround...
DWORD dw = (DWORD) p; // move in the array using this
Base* p2 = NULL;
for(int i=0;i<4;i++)
{
p2 = (Base*) dw;
p2->y=10;
dw += sizeof(Derv); // move to the next elem
}
What do you think??
Clinton
|
|
|
|
|
Nice trying Clinton!
If you come up with a better solution, do let me know
chao!
...Avenger
Remember... testing & debugging are always part of programming ...so exterminate those stinking bugs
|
|
|
|
|
hey, looking your code, i cannot see any inheritence between your two classes.
you must tell that Derv is derived from Base (public, protected or private as you like...) :
<font color=#0000FF>class </font>Base {
<font color=#0000FF>public</font>:
<font color=#0000FF>int </font>x;
<font color=#0000FF>virtual void </font>f();
};
<font color=#0000FF>class </font>Derv : public Base {
<font color=#0000FF>public</font>:
<font color=#0000FF>int </font>y;
<font color=#0000FF>void </font>f();
};
avenger_sb25 wrote:
Suppose the derived class array was allocated at 0x00000000
impossible, nothing can be allocated at the address 0x00000000 (and even the operating system don't !). you must test if the address returned by new is different from NULL ((void*)0x00000000 ) :
Base* p;
p = <font color=#0000FF>new </font>Derv[4];
<font color=#0000FF>if </font>(p != NULL) {
<font color=#0000FF>for</font> (<font color=#0000FF>int </font>i = 0; i < 4; i++) {
p[i]->y = 10;
}
<font color=#0000FF>delete</font>[] p;
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hi,
I'm debugging one of my mfc programms. I'm using a ON_COMMAND map thing to respond to a popup menu command...
When i´m debugging this function the debugger tells me that this is 0x00000000....
This cause a lot of trouble... And it seems that this is changing from time to time...
Sometimes it's a pointer to an array, sometimes something else...
I find this really wierd...
|
|
|
|
|
Sounds like you are some how calling a class member function when the class no longer exist in memory. Which is the only time this should be NULL. Why it would ever be pointing to any thing else is anouther question.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I concur with John's statement.
As for your question of "pointing to something else", I've found the best solution is initialising every single pointer you use. It might seem a bit tedious with a "CMyClass* ptr = NULL;" line in every place, but at least it prevents debugging headaches!
Clinton
|
|
|
|
|
It's just that the class member i'm calling does still exist in memory.
The function is a member of a CView-derrived class. And the view still exixsts!
And sometimes i can use the data members of the class in a proper way. And when i debug the code
this is changing!
|
|
|
|
|
WOW! That's some bug...
Hmm, lets see... if after this "change" occurs once and you cannot access your members properly thereafter, it could mean some copy function is playing foul and overwriting its buffer,...
but, if you can access your members correctly "now-and-then", well... all I can think of... is a pointer-to-view pointing to the wrong place...
Clinton
|
|
|
|
|
Hi Guys
I have a problem(why else should i post here?). I only now the executable's name and it is sure that it is running. How can i get the HWND by just knowing the name of the file ?
Please Help !!
MFG
RedDragon2kx
Unix and C are the ultimate computer viruses.
|
|
|
|
|
Hi,
You can use the SPY++ Utility which comes with Visual Studio Tools
Sujan
|
|
|
|
|
RedDragon2k wrote:
have a problem(why else should i post here?). I only now the executable's name and it is sure that it is running. How can i get the HWND by just knowing the name of the file ?
Here Are the apis that will help you Out
->GetModuleHandle
->GetModuleHandleEx
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Thanks a lot !!! ;)
Unix and C are the ultimate computer viruses.
Visit me: www.programming.info.ms
|
|
|
|
|
WinDbg and Microsoft support believe there is a memory leak in this function. I don't see it, but I'm not a guru. Can you see it?
void CClientSession::WriteTableListGetQueryListRS(
BOOL bDetails,
CString strTable,
enum eTable tableSave,
BOOL & bDeniedAccess,
BOOL & bDeniedAccessOther,
CStringArray & arrFields,
CArray<long, long=""> & arrLookups,
long & lLookup,
long & lPrimarySortField,
CString & strPrimarySortField,
CString & strPrimarySortOrder,
CString & strFields,
CString & strJoin,
CString & strWhere,
CString & strSQL)
{
CString strField;
CString strListFields;
CString strOrderBy;
TRY
{
if (bDetails && !m_pExt->GetServerPtr()->GetDeptView(strTable, m_lDeptID))
return NULL;
bDeniedAccess = m_pExt->GetServerPtr()->GetTableAccess(strTable, FALSE,
m_stateCurrent.m_strMainTable, m_stateCurrent.m_lMainRecord,
m_stateCurrent.m_strDepTable, m_stateCurrent.m_lDepRecord,
m_lDeptID, m_lCompanyID);
if (GetFunc() == CMD_SUMMARY)
bDeniedAccessOther = m_pExt->GetServerPtr()->GetTableAccess(strTable, FALSE,
m_stateCurrent.m_strMainTable, m_stateCurrent.m_lMainRecord,
"", -1, m_lDeptID, m_lCompanyID);
else if (bDeniedAccess)
return NULL;
if (bDeniedAccessOther)
return NULL;
// strFields i.e.: Person.Last_Name, Statuses.Company_ID, etc.
int nFind = strPrimarySortField.Find('.');
strPrimarySortField = strPrimarySortField.Mid(nFind + 1);
if (m_pExt->GetServerPtr()->GetDependencyCount(m_stateCurrent.m_strMainTable))
m_stateCurrent.m_strDepTable = m_pExt->GetServerPtr()->GetDependency(m_stateCurrent.m_strMainTable, 0);
if (!bDetails)
{
if (strTable == m_stateCurrent.m_strMainTable && !m_stateCurrent.m_strDepTable.IsEmpty())
{
if (strJoin.Find(" LEFT OUTER JOIN " + m_stateCurrent.m_strDepTable) == -1)
{
strJoin = " LEFT OUTER JOIN " + m_stateCurrent.m_strDepTable + " ON " + m_stateCurrent.m_strDepTable + "." + m_stateCurrent.m_strMainTable + "_ID=" + m_stateCurrent.m_strMainTable + ".ID" + strJoin;
strFields = m_stateCurrent.m_strDepTable + ".ID," + strFields;
}
}
else if (m_stateCurrent.m_eTable == Sub)
{
strJoin = " INNER JOIN Statuses ON Statuses.ID = " + strTable + ".Person_IDS";
}
//Add to SELECT fields
strFields = "," + strFields + GetSQLFields(strTable);
// Search Fields
if (GetFunc() == CMD_SEARCH)
{
CString strSearchField;
if (!GetCookie(GetTable() + ".SearchText").IsEmpty())
{
strSearchField = GetCookie(m_stateCurrent.m_strMainTable + ".SearchField");
if (strFields.Find("," + strSearchField + ",") == -1)
if (strFields.Find(strSearchField, strFields.GetLength() - strSearchField.GetLength()) == -1)
strFields += "," + strSearchField;
}
if (!GetCookie(GetTable() + ".SearchText2").IsEmpty())
{
strSearchField = GetCookie(m_stateCurrent.m_strMainTable + ".SearchField2");
if (strFields.Find("," + strSearchField + ",") == -1)
if (strFields.Find(strSearchField, strFields.GetLength() - strSearchField.GetLength()) == -1)
strFields += "," + strSearchField;
}
strSearchField.Empty();
}
//Build Sort Order
CString strColumn;
for(int nColumn = 0 ; nColumn < 3 ; nColumn++)
{
strColumn.Format("%s.Sort%d", strTable, nColumn);
strColumn = GetCookie(strColumn);
nFind = strColumn.Find('.');
if (nFind != -1)
strColumn = strColumn.Mid(nFind + 1);
if (!strColumn.IsEmpty())
if (strOrderBy.Find(strColumn) == -1)
AddSortColumn(strTable, strColumn, strOrderBy);
}
//Build Sort Order part 2
if (strOrderBy.IsEmpty())
{
CString strOrder = m_pExt->GetServerPtr()->GetDefaultOrderBy(strTable) + ",";
CString strSort;
nFind = strOrder.FindOneOf(", ");
nColumn = 0;
while (nFind != -1)
{
strOrderBy += strTable + "." + strOrder.Left(nFind);
if (strOrder[nFind] == ' ')
nFind = strOrder.Find(',');
strOrder = strOrder.Mid(nFind + 1);
nFind = strOrder.FindOneOf(", ");
if (nFind != -1)
strOrderBy += ',';
}
strOrder.Empty();
strSort.Empty();
}
CString strTableField;
strFields += ",";
strFields = strFields.Mid(1);
int nDot;
long lField = 0;
/*
strListFields
*/
nFind = strFields.Find(',');
while (nFind != -1)
{
strTableField = strFields.Left(nFind);
nDot = strTableField.Find('.');
if (nDot != -1)
{
strField = strTableField.Mid(nDot + 1);
strTableField.ReleaseBuffer(nDot);
}
else
{
strField = strTableField;
strTableField = strTable;
}
strFields = strFields.Mid(nFind + 1);
lLookup = m_pExt->GetServerPtr()->GetLookup(strTableField, strField);
arrLookups.Add(lLookup);
arrFields.Add(strField);
strTableField = AddFieldSQL(lLookup, lField, strJoin, strWhere, strOrderBy);
//Only display columns that aren't set to hidden in TableFields.Dept_Visible
if (m_pExt->GetServerPtr()->GetLookupHiddenView(lLookup, m_lDeptID) == FALSE)
{
if (!strListFields.IsEmpty())
strListFields += ",";
strListFields += strTableField;
}
if (lPrimarySortField == -1
&& m_pExt->GetServerPtr()->GetLookupTable(lLookup) + "." + strField == strPrimarySortField)
{
lPrimarySortField = lField;
strPrimarySortField = strTableField;
}
lField++;
nFind = strFields.Find(',');
}
strColumn.Empty();
strTableField.Empty();
}
else
strListFields = "COUNT(ID)";
strSQL = "SELECT " + strListFields + " FROM " + strTable + strJoin + strWhere;
if (!strOrderBy.IsEmpty())
strSQL += " ORDER BY " + strOrderBy;
OutputDebugString(strSQL + "\r\n");
}
CATCH_ALL(e)
{
DumpError(e, __FILE__, __LINE__);
m_stateCurrent.m_eTable = tableSave;
return NULL;
}
END_CATCH_ALL
WriteResponseDebug(strSQL);
strSQL.Empty();
strField.Empty();
strListFields.Empty();
strOrderBy.Empty();
}
<signature>
It's good to live,
Josef Wainz
Software Developer
|
|
|
|
|
Is is possible to convert an existing application(MFC) into an activex control so that it can be embedded into internet explorer. If so how can i can go about it?
Thanks
|
|
|
|
|
create an activex project and implement every function in the exe in to that ocx ,
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
Dear all,
I used a truecolor icon for my application. Unfortunately, Win NT does not support truecolor icon. How can I change the icon to a 256-color one (in run-time) when it runs in Win NT4?
Best regards,
|
|
|
|
|
|
Thanks Anders,
It worked!!
BRs.
|
|
|
|
|
I just converted to VS7 and had to change some things around.
My good old #include <fsream.h> did not work anymore, so I converted to CStdioFile.
the problem is that now, the "\n" is not being printed out to the file, even though the microsoft site claims WriteString shoud do it.
Here is my code:
<br />
CStdioFile log_file (_T(file.txt"),CFile::modeWrite | CFile::modeCreate | CFile::typeText);<br />
<br />
CString h="Hello\nThere";<br />
log_file.WriteString (h);<br />
<br />
The expected output is:
Hello
There
But I get:
HelloThere
|
|
|
|
|
I think you get the output that way 'cos the file was opened in typeText.
I'd be interested to know if it worked with
"Hello\r\nThere".
Clinton
|
|
|
|
|
Are there example on DrawDragRect?
I need one specific dealing when the object is drag outside the window.
Case 1: Assume L mouse click is release when it's outside the window
Case 2: Don't assume mouse is release. Check mouse status when it reenters the window.
The other thing I would like to do is change mouse icon if it's drag outside the window range with L mouse click still down.
Thanks
|
|
|
|
|
|