|
What I meant is: try to give more details. "It doesn't work" is way too vague. Did you have a compilation error, a run-time crash, your computer exploded, ... ?
Keep in mind that we can't see what's on your screen.
|
|
|
|
|
wbgxx wrote: "Microsoft"
?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In your constructor you set buffer to NULL.
In your main function you just create an instance of CBuffer and call SaveString.
SaveString accesses your buffer (what is NULL), so you get an access violation.
int main ()
{
CBuffer buffer1;
buffer1.Allocate(4096);
buffer1.SaveString("Microsoft");
printf("%s", buffer1.GetBuffer());
return 0;
}
Greetings
Covean
|
|
|
|
|
Maybe he needs a new pair of sneakers?
The wonderful thing about the Darwin Awards is that everyone wins, especially the members of the audience.
|
|
|
|
|
I want to create a round rect button with three image , one for left round, one for middle and one for right round. Middle image I m rendring according to with of button, but I don't know how to use the both side images so that my button sud look like reound rectangular.
Here is my code to render the middle image.
void CRoundButton2::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// Get DC of Item
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
ASSERT (pDC != NULL);
// Should Buttons be generated?
bool bGenerate = !m_rBtnSize.EqualRect(&lpDrawItemStruct->rcItem) || m_bRedraw;
// If Rectangles of Button are not the same
if (bGenerate)
{
// Generate Bitmap to hold Buttons
GenButtonBMPs(pDC, lpDrawItemStruct->rcItem);
// Redraw done
m_bRedraw = false;
}
// Generate DC to draw in Memory
CDC *MemDC = new CDC();
MemDC->CreateCompatibleDC(pDC);
HGDIOBJ hOldBmp = MemDC->SelectObject(m_tBmpBtn);
CString sActualCaption;
// Get actual caption
GetWindowText(sActualCaption);
// Check, if caption has changed
if (sActualCaption != m_sOldCaption)
bGenerate = true;
// Store old caption
m_sOldCaption = sActualCaption;
// If Rectangles of Button are not the same
if (bGenerate)
{
// Draw Buttons
DrawButtonFace(MemDC);
// Draw Button-Caption
DrawButtonCaption(MemDC);
}
int nButtonState;
nButtonState = BS_ENABLED;
if (m_bIsHotButton && m_bMouseOnButton)
nButtonState = BS_HOT;
if ((lpDrawItemStruct->itemState & ODS_DISABLED) == ODS_DISABLED)
nButtonState = BS_DISABLED;
else
{
if ((lpDrawItemStruct->itemState & ODS_SELECTED) == ODS_SELECTED)
nButtonState = BS_PRESSED;
else
{
if (this->m_bIsChecked)
{
nButtonState = BS_CLICKED;
}
}
}
CBitmap bitmap2;
bitmap2.LoadBitmap(IDB_BITMAP1);
BITMAP bmpInfo;
bitmap2.GetBitmap(&bmpInfo);
CBitmap* pOldBitmap = MemDC->SelectObject(&bitmap2);
//int nX = m_rBtnSize.left + (m_rBtnSize.Width() - bmpInfo.bmWidth) / 2;
//int nY = m_rBtnSize.top + (m_rBtnSize.Height() - bmpInfo.bmHeight) / 2;
// Copy correct Bitmap to Screen
for ( int i = 0 ; i<117 ; i++)
{
MemDC->SelectObject(bitmap2);
pDC->BitBlt(0+i,0,bmpInfo.bmWidth,bmpInfo.bmHeight, MemDC,0, 0, SRCCOPY);
//MemDC->SelectObject(hOldBmp);
MemDC->SelectObject(pOldBitmap);
}
UINT state = lpDrawItemStruct->itemState; //Get state of the button
if ( (state & ODS_SELECTED) ) // If it is pressed
pDC->DrawEdge(m_rBtnSize,EDGE_SUNKEN,BF_RECT); // Draw a sunken face
// else
// pDC->DrawEdge(rt,EDGE_RAISED,BF_RECT); // Draw a raised face
}
Please help me out..
Thanks in Advance
|
|
|
|
|
Dear All,
I am unable to use the Api ::CreateFileMapping(...) in Windows7 Version and Vista for Elivated User.
Please give me solution for this.
Thanks & Regards,
Uday.
|
|
|
|
|
|
char *my_strcpy(char *p1, char *p2)
{
if (p2 == NULL )
return p1;
if (p1 == NULL)
return 0;
else
{
char *pp1 = p1;
char *pp2 = p2;
while (p2 != '\0')
{
*p1++ = *p2++;
}
*pp1 = '\0';
}
return p1;
}
Is there something wrong in my function and why? Thanks in advantage
|
|
|
|
|
char *my_strcpy(char *p1, char *p2)
{
if (p2 == NULL )
return p1;
if (p1 == NULL)
return 0;
else
{
char *pp1 = p1;
char *pp2 = p2;
while (p2 != '\0')
{
*p1++ = *p2++;
}
*pp1 = '\0';
}
return p1;
}
|
|
|
|
|
wbgxx wrote: Is there something wrong in my function
Have you tested it? What makes you think there's something wrong with it?
|
|
|
|
|
sorry,I can not test it ,can you tell me how to do it ?
|
|
|
|
|
wbgxx wrote: sorry,I can not test it ,can you tell me how to do it ?
Well, how do you intend to become a developper ??
Anyway, you have a couple of choices.
- simulate it on paper (run it by hand, line by line with a pencil and some paper).
- run it in a debugger (Visual Studio has a good one).
Max.
Watched code never compiles.
|
|
|
|
|
|
Well try stepping through it with your eyes (aka reading) one line at a time. Then when you get to the line that reads
*p1++ = *p2++;
ask yourself what is the purpose of pointer pp1 . This looks a bit like the sort of confusion that arises from not using useful variable names.
It's time for a new signature.
|
|
|
|
|
The first two if() tests are not necessary. Also, pp2 is not necessary.
wbgxx wrote: while (p2 != '\0')
This will not terminate like you want it to.
Richard hints at the last piece of the puzzle.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have the following weird problem on customer's computer (I cannot look in there and debug):
OS: WinXP
Application: MFC app on Visual C++ 6
There is a simple CDialog-based dialog that always worked OK. But on one of customer's computers the dialog hangs as soon as it is called. I managed to gather dump on it, and this is what I see in Call Stack:
ntdll.dll!_KiFastSystemCallRet@0()
user32.dll!_NtUserDispatchMessage@4() + 0xc bytes
user32.dll!_DispatchMessageW@4() + 0xf bytes
mfc42u.dll!CWinThread::PumpMessage() + 0x3a bytes
mfc42u.dll!CWnd::RunModalLoop() + 0xc6 bytes
mfc42u.dll!CDialog::DoModal() + 0xc7 bytes
If I understood memory dump right, the message id is WM_PAINT. So the dialog probably receives endless WM_PAINT messages and is busy redrawing itself. Why is that? As I said, this is simple About dialog that worked well million times.
|
|
|
|
|
i am trying to use this for identifying appended lines to the files
|
|
|
|
|
I am not sure you can do this, select() is used to test network sockets rather than file descriptors.
It's time for a new signature.
|
|
|
|
|
Please can someone tell me how to track single/multiple cell insert/delete event in Excel.
I have done with most of the events but fighting for this ? please suggest .....
We can add cells through context menu option (Right click) and Menu option ...but what are the events in C++ to catch this ...
|
|
|
|
|
The Workbook object has a 'SheetChange' event. The Worksheet object has a 'Change' event. Either of these will be fired if you change that worksheet..
So, if you have a workbook that contains Sheet1, Sheet2 and Sheet3, the SheetChange event of the workbook will be fired when ANY of Sheet1, Sheet2 and Sheet3 change. Sheet1 will fire the 'Change' event when it is changed. Sheet2 will fire the 'Change' event when it is changed. Sheet3 will fire the 'Change' event when it is changed. Simple as.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi Stuart,
When cell is inserted, only cell where the new cell is inserted or deleted will be tracked in sheetchange event. But whereas the allignment of data cannot be tracked.
For example: if following is the data before cell insert
c0 c1 c2 c3
r0 1 2 3 4
r1 2 3 4 5
r2 3 4 5 6
If say I have inserted cell at r1c1 then the allignment of data after cell insert will be:
c0 c1 c2 c3 c4
r0 1 2 3 4
r1 2 * 3 4 5
r2 3 4 5 6
* represents blank cell is inserted.
How to track this change in allignment? For above example allignment change data will be:(r1c2:3,r1c3:4,r1c4:5)
Following is the code in sheet change:
_bstr_t result= target->GetAddress(1,1,Excel::XlReferenceStyle::xlR1C1,1,1);
In result we are getting only r1c1.
As of now we are able to do it when user inserts the cell using context menu: right click->insert, this we are tracking in sheetbeforerightclick, where we are setting the bool flag , and immediately in sheet change we are checking the same bool flag for true , if it is true then we are reading that complete row and complete col.But this will not work when user inserts/deletes the cell through menu.
Please guide us to get this change in allingment of data for all the four options: cell insert/delete(shift cells right, shift cells down)/(shift cells up, shift cells left) when user inserts cell either through context menu or menu.
Thanks in Advance,
Regards,
KTTransfer.
|
|
|
|
|
It doesn't look like you can do that....
Which leads to the question WHY are you trying to track these changes? What's the higher level requirement? There is likely some other, better way of achieving what you really need....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
yes ..we need to track these changes for better optimization..If suppose somebody ass /deletes single /multiple cells in sheet then as described other cells will get shift to newer positions ..so we nned to update these changes to some server ...to be in sync with sheets ..but we dont want to send whole
data from sheet again to server ..we just want to send latest updated cell ..so we need this event to track this cells...
|
|
|
|
|
Sounds like your optimisation strategy isn't feasible...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
OK ..we have achived this in most of the events ..only this is missing ...anyways ..so according to u for this changes in sheet we need to send complete image of shet to server ?
is that so ?
|
|
|
|