|
hi,
try to look at much simpler code :
void CMyDlg::GetYesterday()
{
SYSTEMTIME st;
GetLocalTime(&st);
FILETIME ft;
SystemTimeToFileTime(&st,&ft);
__int64 longTime;
memcpy(&longTime,&ft,sizeof(longTime));
longTime -= (__int64)10000000*60*60*24;
memcpy(&ft,&longTime,sizeof(ft));
FileTimeToSystemTime(&ft,&st);
}
hope this helps you
Yaron
Ask not what your application can do for you,
Ask what you can do for your application
|
|
|
|
|
Hi,
I'm trying to add a tabcontrol to a treeview the followig way: But I don't see any tab in the treeview, just the tree control is there.
Where am I wrong?
Please advise.
void CTreeTestView::OnInitialUpdate()
{
CTreeView::OnInitialUpdate();
CTreeCtrl& tree = GetTreeCtrl();
CRect rct = CRect(1, 10, 100, 0);
cMyTabCtrl.Create(TCS_TABS | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
rct, this, 0x1098);
TC_ITEM tcItem;
tcItem.mask = TCIF_TEXT;
PSTR pszTabItems = "hello";
tcItem.pszText = pszTabItems;
tcItem.cchTextMax = strlen(pszTabItems);
cMyTabCtrl.InsertItem(0,&tcItem);
cMyTabCtrl.SetCurSel(0);
tree.DeleteAllItems();
if (!bXMLTreeCreated)
{
m_ImageList.Create(IDB_BITMAP1, 13, 4, RGB( 255, 255, 255 ));
tree.SetImageList( &m_ImageList, TVSIL_NORMAL );
bXMLTreeCreated = true;
}
hierarchy newNode = hierarchy("Root", "", "", "$Root$", "", false, false, "", 0 );
m_pFormView->cSharedData.HNode [iHierarchyNodeCount++] = newNode;
HTREEITEM hItem = tree.InsertItem( "Root", 4,5,TVI_ROOT );
tree.SelectItem (hItem);
tree.SetItemState(hItem, TVIS_BOLD, TVIS_BOLD );
for (int iCount = 0 ; iCount <15 ; iCount++)
OnPopupInserta();
// TODO: You may populate your TreeView with items by directly accessing
// its tree control through a call to GetTreeCtrl().
}
|
|
|
|
|
Hi,
The follwoing code adds the tab control. but, how can i position it so that it is always at the bottom of the tree view and how can set size of tree control in the tree view so that it doesn't overlap with tab control?
static bool bXMLTreeCreated = false; //this bool is used to make sure image list is added only once
iAttributeNodeCount = 0; //Count of Attribute Nodes, even if deleted not decreased
iHierarchyNodeCount = 0; //Count of Hierarchy Nodes, even if deleted not decreased, not changed if Hierarchy appears twice
uniqueHierarchyCount = 0;
m_pFormView->mapsCount = 0;
m_pFormView->domNodeCount = 0;
lastSelectedItem = NULL;
CTreeView::OnInitialUpdate();
CRect rct = CRect(20,390,280,430);
cMyTabCtrl.Create(TCS_TABS | WS_CHILD | WS_VISIBLE, rct, this, 0x1098);
TC_ITEM tcItem [2];
PSTR pszTabItems [2] = {"Hierarchy", "Device Groups"};
for (int iCount =0 ; iCount <2 ; iCount++)
{
tcItem[iCount].mask = TCIF_TEXT;
tcItem[iCount].pszText = pszTabItems[iCount];
tcItem[iCount].cchTextMax = strlen(pszTabItems[iCount]);
cMyTabCtrl.InsertItem(0,&tcItem[iCount]);
}
cMyTabCtrl.SetCurSel(0);
|
|
|
|
|
hi, I trying to optimize the following subroutine. I was advised that statements like: "sum += (j*16 +1);" should be done using shift and bitwise OR... just exactly how?
I do understand bit flag/masking. But what does multiplication/addition has to do with it? Why'd it optimize code? Can someone show me how to multiply two numbers using bitwise SHIFT/AND/OR...etc?
Thanks.
norm
|
|
|
|
|
Well, first off you shouldn't use shifting for math if you care about code readability. The compiler will optimize your expressions for you, optimizing by hand is largely futile unless you're already writing assembly.
Anyhoo, shifting and multiplying/dividing by powers of 2 are equivalent:
x * 2 == x << 1<br />
x * 4 == x << 2<br />
x * 8 == x << 3
and so on. Similarly,
x / 2 == x >> 1<br />
x / 8 == x >> 3
Since a bit shift instruction can be executed in fewer clock cycles then the corresponding integer math instruction, using shift gives you (theoretically) faster code, although with CPUs these days it's not something a human would ever notice.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
Ericahist updated Aug 30!
|
|
|
|
|
Just adding to Michael's answer, the compiler is most likely to do this kind of replacing itself (it is smart enough to know that multiplying by 16 is equivalent to shifting), so your speed gain is most probably 0. To outsmart the compiler in this type of expressions, you should be knowing something that the compiler cannot possibly find out. For instance, suppose you've got an expression like:
sum+=j*i+1; and you know that i is always a power of 2. Then you can actually have some speedup by replacing i with its log2 in the code and doing the shifting.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hum... i don't quite get it. In my example, i=16 (always)..
so, i do:
sum = sum | j<<4 | 3;
norm
|
|
|
|
|
You may not need to do your hand optimization. Most modern compilers will optimize multiplication and division of certain integer constants (2,3,4,5,any power of 2, and so on), into the appropriate set of shifts.
Software Zen: delete this;
|
|
|
|
|
Hi. How can we launch program from resources using C++.net?
|
|
|
|
|
I want to have my app look at another app running on my computer, and tell me whether the pixel at a certain location is black or white. Can that be done? How do I refer to the other apps coordinates?
|
|
|
|
|
Hi, I need to compute duration of a method call in millisecond, how can I do that? I'm using _ftime to retrieve time. It has millisecond resolution, according to MSDN:
millitm field of __timeb64 is: "Fraction of a second in milliseconds."
--> Now, from when to when in millisecond?
--> Does operating system actually do millisecond? Assuming MS Windows.
--> difftime( ) precision up to second. Anything for millisec?
Thanks!
************************************************
Anyway, Here's the code:
_ftime64( &timebuffer );
timeline = _ctime64( & ( timebuffer.time ) );
printf( "Start: %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );
//Time consuming method call:
obj->SomeMethod(..);
_ftime64( &timebuffer );
timeline = _ctime64( & ( timebuffer.time ) );
printf( "Finish: %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20] );
norm
|
|
|
|
|
Have a look at QueryPerformanceCounter and QueryPerformanceFrequency
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
I remember having to do this exact same thing when I was in school. This might help out.
#include <time.h>
clock_t Clock1 = clock();
obj->SomeMethod(..);
clock_t Clock2 = clock();
printf( "%.3f seconds", ((float)(Clock2-Clock1))/CLOCKS_PER_SEC );
I didn't look these functions up, but I believe the clock() function returns the number of clock ticks since the program (or maybe the current thread) has begun. You have to cast Clock2-Clock1 to a double or a float or you'll just be performing integer division, which won't give you the answer you are looking for. I suspect you are wrapping the clock calls around sorting algorithms or something of that nature...good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
These functions have millisecond precision, but not millisecond accuracy. In other words, while the result may be expressed as +/- 0.001 second, it may actually only be good to +/- 0.010 second (the Windows 'quantum'), for example. The difference is due to the fact that this clock is based on Windows timekeeping, which may not be updated often enough.
As someone else mentioned, use QueryPerformanceCounter and QueryPerformanceFrequency instead. These functions use a hardware timer that is not dependent on Windows.
Software Zen: delete this;
|
|
|
|
|
|
In winamp,the 3 dialog can attach to each other.When the main dialog moves.the child dialog move according to the main dialog.When there is only one child dialog,this is easy to do so.But if we have multi child dialog,when
moving,that is very complicated.Is there any good ideas? thanx!
|
|
|
|
|
that's an interesting question
norm
|
|
|
|
|
Hi,
I have this little part of code:
<br />
char* echoReply = new char[1024];<br />
int nRet;<br />
int nAddrLen = sizeof(struct sockaddr_in);<br />
sockaddr_in lpsaFrom;<br />
lpsaFrom.sin_family = AF_INET;<br />
lpsaFrom.sin_port = 0;<br />
<br />
nRet = recvfrom(s,<br />
(char*) &echoReply,<br />
1024,<br />
0,<br />
(sockaddr*) &lpsaFrom,<br />
&nAddrLen);<br />
<br />
if (nRet == SOCKET_ERROR)<br />
<br />
int error = WSAGetLastError();<br />
nRet (the return value of recvfrom) is 0xffffffff (SOCKET_ERROR)
but WSAGetLastError returns 0 (no error).
how can this be?
I don't think this is possible.
can anybody help me, please?
Thx
CND
|
|
|
|
|
I have a word file, with some text being bold, some
italic, etc., etc. Is their any way to open the
file and see the code behind the file? In latex, I
would see
\begin{bold}Bold text here\end{bold}
but I would like to see the code behind a ms word
doc file.
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
Word files are COM/OLE Compound Storage. This is what enables them to embed other office (say Excel documents) within them.
look at IStorage - Compound File Implementation
Beyond that Word markup is not publicly published to the best of my knowledge. However a cutdown version of Word markup called "Rich Text Format" is available and was published. It certainly has tags for basic font and paragraph control.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/html/rtfspec.asp
|
|
|
|
|
You might want to take a look at this page... download the doc links and take a look at them. hope this helps.
<url>http://www.wotsit.org/search.asp?s=text
-Tareq
|
|
|
|
|
Hi,
In my SDI application I want the following.
A splitter window splits the window in two parts.
In one part I have a FormView and in the other part I want to have a TreeView and a set of tabs at the bottom, allowing the user to toggle between 2 different TreeViews.
Should I add the CTabControl to the tree or, I’ll add the tab control first? How do I go about it? And do I need to have two separate treeviews, or, I can work with 1 treeview only?
Binayak
|
|
|
|
|
|
I have a couple questions about the CSettingDiaglog class at http://www.codeproject.com/dialog/csettingsdlg.asp[^].
I like to read through the source of projects to increase my knowledge and I had some questions about this source (especially since I'm an MFC genious by no means). What I want to know is if the author makes the assumption that whoever is going to use the class is going to have a dialog that has a button with an ID of IDAPPLY? It's used through out the code, but would only be used in a project that uses the dialog as modeless. I can't see how the code would compile if you didn't have the an IDAPPLY ID defined.
One other question. In the code header there is the following statement:
enum { IDD = IDD_SETTINGS_DLG }; I just want to know if that's how the program knows the dialog it should be showing when you open an instance of the CSettingsDialog class. For example if my dialog ID was IDD_CONFIG_DLG would I change the statement to say:
enum { IDD = IDD_CONFIG_DLG }; Thanks for any and all help/clarification.
I had one more question after posting. Could this code be used in a DLL or would you have to include the source in your project?
Thanks again.
- monrobot13
|
|
|
|
|
Hi
I am very new to MFC but I have some experience with win API and I am very eager to begin programming with MFC but I experiencing some difficulties. Is it possible to create a main frame window with only a dialog resource? So that when the window creates it will include all of the controls configured in the dialog resource. I thank you for any help.
Aidman » over and out
We haven't inherited Earth from our parents, instead we have borrowed her from our children; an old Indian saying.
|
|
|
|
|