|
You can use of CString::Mid.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
thats a real basic homework:
1. find the 2 blank positions
2. extract the chars in between
it is no question it is a sign thats you arent engaged enough for writing code
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Tiyani Miyambo wrote: "Sam james thomas"
strtok(strtok("Sam james thomas", " "), null);
|
|
|
|
|
ahmed zahmed wrote: strtok(strtok("Sam james thomas", " "), null);
Maybe you meant this as a joke. Otherwise, you can't seriously think it would produce the desired result.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
you are correct, it won't produce the desired result. what was i thinking?
strtok("Sam james thomas", " ");
strtok(null, " ");
|
|
|
|
|
I have a thread going on a little way down, about threads and timing. Now a question came up that I felt should go into a different thread.
I have the following code piece
HANDLE hTimerQueue = CreateTimerQueue();
HANDLE hTimer;
count = 0;
CreateTimerQueueTimer(&hTimer, hTimerQueue, (WAITORTIMERCALLBACK)&DoSendHere, 0 , 20, 0, WT_EXECUTEINTIMERTHREAD);
QueryPerformanceCounter(&liStart);
::SleepEx(60, TRUE);
LONG lCount = count;
QueryPerformanceFrequency(&liFreq);
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Time = %f.\n", double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) );
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Count = %d.\n", lCount );
The liEnd variable is filled in the callback function.
Several issues:
1. Like it is the callback func is called once (like intended) but the output gives a time of appx. 30ms, not 20ms. Actually the time is never the time I set up.
2. Why does it crash if I call DeleteTimerQueueTimer( hTimerQueue, hTimer, NULL ); after the output?
The output is this
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030410.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030192.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030377.
RTPEngine: Count = 1.
This is the output for a 9ms dueTime:
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.016252.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014759.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014178.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014759.
RTPEngine: Count = 1.
Souldrift
modified on Monday, July 6, 2009 5:53 AM
|
|
|
|
|
I can't reproduce your results - I always see the timer triggering roughly (within around 2-300 microseconds) when expected.
Note that in my initial post about timer queue timers I posted the wrong callback function signature - that could have caused crashes, as there was an extra formal parameter - sorry about that.
You may find it useful to investigate the different values in the Flags parameter of CreateTimerQueueTimer - the callback doesn't have to execute in the same thread as the timer.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, I made a small adaption to your code like this (some output and another timing behaviour)
#include <windows.h>
#include <tchar.h>
#include <iostream>
LONG count;
LARGE_INTEGER liStart, liEnd, liFreq;
VOID CALLBACK DoSendHere(__in_opt LPVOID lpArgToCompletionRoutine,
__in DWORD dwTimerLowValue,
__in DWORD dwTimerHighValue)
{
QueryPerformanceCounter(&liEnd);
count++;
std::cout << "Time = " << double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) << std::endl;
}
void SendLoop()
{
HANDLE hTimerQueue = CreateTimerQueue();
HANDLE hTimer;
count = 0;
QueryPerformanceFrequency(&liFreq);
CreateTimerQueueTimer(&hTimer, hTimerQueue, (WAITORTIMERCALLBACK)&DoSendHere, 0 , 0, 9, WT_EXECUTEINTIMERTHREAD);
QueryPerformanceCounter(&liStart);
::SleepEx(65, TRUE);
LONG lCount = count;
DeleteTimerQueueTimer(hTimerQueue, hTimer, 0);
std::cout << "Time = " << double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) << std::endl;
std::cout << "count = " << lCount << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
SendLoop();
getchar();
return 0;
}
The result shows the same 15ms jumps I had before. Maybe there´s just no way around. I guess, I think some more and then we might have to settle for a different approach.
Thanks once again for ideas and brainstorming.
Souldrift
|
|
|
|
|
Hej Everyone,
I opened MS word file in NOTEPAD and saved it as text file so that i can read the saved file using C/C++ streams. Below i have given image of MS word file opened in NOTEPAD and then i tried to read it using C/C++ streams but my programs reads the first few characters and then terminates. Why can't i read all these characters?
http://i41.tinypic.com/nybvih.jpg[^]
Any help in this regard will be appreciated.
Thanks
|
|
|
|
|
Post some relevant code snippet otherwise we can't guess what you are doing wrong.
|
|
|
|
|
int main()
{
ifstream file("test.txt");
char ch;
if (file.is_open())
{
while ( !file.eof() )
{
file >> ch;
cout << ch;
}
}
getchar();
return (0);
}
-
This program just read the first few (5 to 6) characters of the MS word file saved as text file. How to read the remaining characters?
|
|
|
|
|
Are you aware that the file contains binary data ? What are you trying to achieve exactly ? Trying to output to the screen a binary file is probably not a good idea...
|
|
|
|
|
@Cédric Moonen
-
Thanks. Let me try it using binary.
-
Thanks everyone.
|
|
|
|
|
Member 6371145 wrote: I opened MS word file in NOTEPAD and saved it as text file so that i can read the saved file using C/C++ streams.
That makes no sense:
- Changing the file extension won't change the (binary) content.
- C/C++ can (of course) read binary content of files.
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]
|
|
|
|
|
Did you tried with binary file mode?
MS word is actually writes in binary mode starts with MS word File header.
|
|
|
|
|
Hi Expert
how to get mysql database path throigh code?
|
|
|
|
|
Path to what part of mysql?
I'm pretty sure that 'path to the database' isn't meaningful - remember that the database can be on a separate machine, on a filesystem you have no visibility of.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
how to Add button inside view class in MFC
modified on Wednesday, July 15, 2009 3:49 AM
|
|
|
|
|
Do you need to Ownerdraw for your button?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
i will explain wht i did. i uploaded a bit map and inthat bit map i draw a rectangle in view OnDraw function.
pDC->Rectangle(x, y, x1, y1);
now wht i want is that whn i click on the rectangle i want another window to b opened.
|
|
|
|
|
You can use of CreateWindow/ShowWindow or DoModal for show other dialogs.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
sounds simple,
just take the onclick event on the view, it will give you, the point,(x,y), clicked.
then use ptinrect(...) function to verify, weather user has clicked on the desired rectangle or not.
hope this should be clear for you.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Create a customized Button
say as below and add a resource button with owner draw and now instead of you button change the CButton with ButtonEx :-
// Color settings.
const COLORREF CLR_FILL_NORMAL = RGB( 255, 250, 192 );
const COLORREF CLR_FILL_HOT = RGB( 255, 255, 225 );
const COLORREF CLR_FILL_PUSHED = RGB( 240, 225, 164 );
const COLORREF CLR_FILL_DISABLED = RGB( 225, 225, 225 );
const COLORREF CLR_BORDER_NORMAL = RGB( 230, 215, 128 );
const COLORREF CLR_BORDER_HOT = RGB( 0, 64, 255 );
const COLORREF CLR_BORDER_PUSHED = RGB( 64, 192, 255 );
const COLORREF CLR_BORDER_DISABLED = RGB( 192, 192, 192 );
const COLORREF CLR_TEXT_NORMAL = RGB( 0, 0, 0 );
const COLORREF CLR_TEXT_HOT = RGB( 0, 0, 192 );
const COLORREF CLR_TEXT_PUSHED = RGB( 0, 0, 0 );
const COLORREF CLR_TEXT_DISABLED = RGB( 128, 128, 128 );
ButtonEx::ButtonEx() : m_bMouseInside( false )
{
}
BEGIN_MESSAGE_MAP(ButtonEx, CButton)
//{{AFX_MSG_MAP(ButtonEx)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDBLCLK()
//}}AFX_MSG_MAP
ON_MESSAGE( WM_MOUSELEAVE, OnMouseLeave )
END_MESSAGE_MAP()
// This function set the owner draw style to the button when it is sub-classed.
void ButtonEx::PreSubclassWindow()
{
ModifyStyle( 0, BS_OWNERDRAW );
CButton::PreSubclassWindow();
}
void ButtonEx::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
// Get the dc as CDC object.
CDC dc;
dc.Attach( lpDrawItemStruct->hDC );
// Get the button rectangle as CRect object.
CRect rect( lpDrawItemStruct->rcItem );
// Get the button caption.
CString csCaption;
GetWindowText( csCaption );
// Variables for keeping the drawing colors.
COLORREF clrFill, clrBorder, clrText;
// Check the state of the button.
// First of all we have to check the enable/disable state.
if( ODS_DISABLED == ( lpDrawItemStruct->itemState & ODS_DISABLED ))
{
// Disabled state.
clrFill = CLR_FILL_DISABLED;
clrBorder = CLR_BORDER_DISABLED;
clrText = CLR_TEXT_DISABLED;
}
else
{
// Enabled state.
if( ODS_SELECTED == ( lpDrawItemStruct->itemState & ODS_SELECTED ))
{
// Button is pushed/pressed.
clrFill = CLR_FILL_PUSHED;
clrBorder = CLR_BORDER_PUSHED;
clrText = CLR_TEXT_PUSHED;
}
else
{
// If the mouse is inside the button area then show the hot colors.
if( m_bMouseInside )
{
clrFill = CLR_FILL_HOT;
clrBorder = CLR_BORDER_HOT;
clrText = CLR_TEXT_HOT;
}
else
{
clrFill = CLR_FILL_NORMAL;
clrBorder = CLR_BORDER_NORMAL;
clrText = CLR_TEXT_NORMAL;
}
}
}
// Fill the background.
dc.FillSolidRect( &rect, clrFill );
// Draw the border.
dc.Draw3dRect( &rect, clrBorder, clrBorder );
rect.DeflateRect( 1, 1 );
dc.Draw3dRect( &rect, clrBorder, clrBorder );
// Draw the caption.
dc.SetTextColor( clrText );
dc.SetBkMode( TRANSPARENT );
dc.DrawText( csCaption, &rect, DT_VCENTER | DT_CENTER | DT_SINGLELINE );
// Detach the dc from CDC object.
dc.Detach();
}
// This function will track the mouse movement and handle the mouse enter and mouse leave.
void ButtonEx::OnMouseMove(UINT nFlags, CPoint point)
{
// If the mouse was outside then the mouse is just entered the button area.
if( !m_bMouseInside )
{
// Set the flag.
m_bMouseInside = true;
// Update the display to reflect the hot state.
Invalidate( FALSE );
// Register the mouse-track to get the mouse leave message.
TRACKMOUSEEVENT stTME = { 0 };
stTME.cbSize = sizeof( stTME );
stTME.dwFlags = TME_LEAVE;
stTME.hwndTrack = m_hWnd;
_TrackMouseEvent( &stTME );
}
// Nothing to do special if the mouse is already inside the button area.
CButton::OnMouseMove(nFlags, point);
}
// This function will handle the mouse leave from the button area.
LRESULT ButtonEx::OnMouseLeave( WPARAM, LPARAM )
{
// Reset the flag.
m_bMouseInside = false;
// Update the display to reflect the hot state.
Invalidate( FALSE );
return 0; // Not used.
}
// This function will make the double click event to single click.
void ButtonEx::OnLButtonDblClk( UINT nFlags, CPoint point )
{
const MSG* pstMSG = GetCurrentMessage();
DefWindowProc( WM_LBUTTONDOWN, pstMSG->wParam, pstMSG->lParam );
}
Hope you are looking for this.
|
|
|
|
|
|
Hi all,
i want to send service message to recipient i m using Mapi for sending msg but its not send service msg,
service msg means its open on recipient mobile screen and delete when user exit the mobile screen.
i think
MESSAGEFIELDS or IMessageFormHostEx,or IFormProviderEx api's can be use for this.
i dont know how can i use it please help me how can i use it.
if possible please provide me any sample code.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|