|
As a guess, and assuming that the CtreeCtrl has a copy constructor, you may be able to use the CreateDialogParam function to pass the address of the current one to the dialog as the lParam of the WM_INITDIALOG message and then assign it (copy construct it) to the copy. Of course if you can do that then you may be able to just add a member to the dialog class and assign it there, during construction. Another option would be to find away to separate it so that a function call from the view or the dialog so that either one can access it, but I do not know if that is possible.
Like I said, I am just guessing here because I am out of practice and have not done it myself.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi all. I've found out how to keep a function from repeating the same string over and over. But i have another challenge. I was wondering if i could pick out certain chars etc. So i decided to play with strstr. But i have 2 errors. Here a sample code of the time function im using.
<br />
#include <time.h><br />
#include <windows.h><br />
#include <fstream><br />
using namespace std;<br />
<br />
int main (){<br />
char olddate[9] = {0}, oldtime[9] = {0};<br />
while(1){<br />
Sleep(300);<br />
char date [9];<br />
char time [9];<br />
_strdate(date);<br />
_strtime(time);<br />
bool fNewDate = strcmp(date, olddate) != 0;<br />
bool fNewTime = strcmp(time, oldtime) != 0;<br />
if(fNewDate || fNewTime){<br />
ofstream file1;<br />
file1.open("time.txt",ios::app);<br />
if(strstr(fNewDate,"1/13/07"){<br />
file1 << "[Date]: " << date << endl;<br />
strcpy(olddate, date);<br />
}<br />
if(strstr(fNewTime,"5:30"){<br />
file1 << "[Time]: " << time << endl;<br />
strcpy(oldtime, time);<br />
}<br />
file1.close();<br />
}<br />
}<br />
return 0;<br />
}<br />
The idea is to match a string like "1/13/07" with another string from the time function and save to the file. But instead i get 2 errors.
<br />
error C2664: 'strstr' : cannot convert parameter 1 from 'bool' to 'const char *'<br />
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast<br />
Any suggestions?
|
|
|
|
|
You are passing 'fNewDate' and 'fNewTime', which are bools, to 'strstr' at two different places in your code, instead of a string.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
From the MSDN
char *strstr( const char *string, const char *strCharSet ); But your value is bool fNewTime
|
|
|
|
|
Hi,
I need a control where I can view 32x32 icons to the left side (32bit color depth if possible) along with some information placed to the right of the icons (to make it clearer, I just need something like a listview control in report mode with 32x32 icons instead of the 16x16 icons), is it possible to have 32x32 icons in a listview control in the report mode or do I have to use subclassing? In case that I have to use subclassing, which control do you think I should use? ListView, ListBox, TreeView or some other control? Or finally do you think I should write my own control from scratch?
Thanks in advance,
Wal
|
|
|
|
|
You can use whatever size image list you want in a list control. 32x32 and 16x16 are the most-commonly-used sizes, but there's no rule that you have to stick to those sizes.
|
|
|
|
|
How can I set Attached or Detached second monitor in win32?
|
|
|
|
|
Call GetSystemMetrix() and pass SM_CXVIRTUALSCREEN/SM_CYVIRTUALSCREEN as the parameter. The call would return the size of the virtual screen of all monitors.
Best,
Jun
|
|
|
|
|
i compile in debug mode & there is no run-time or exception!
But when i compile in release mode there is __non_rtti_object exception!
how can i find which pointer is null that cause this exception in release mode?
Best Regards,
M.J.M.
|
|
|
|
|
How can I find the corresponding country of an IP address?
modified 8-Mar-17 3:51am.
|
|
|
|
|
|
|
I am unable to obtain a pointer to the interface INetConnectionCommonUi.
I have called INetConnectionManager's and INetConnectionManagerEvents's QueryInterface with the IID_INetConnectionConnectUi. No go.
I have tried using ::CoCreateInstance using CLSID_ConnectionManager and IID_INetConnectionConnectUi and cannot instantiate this INetConnectionCommonUi.
In both instances, E_NOINTERFACE is returned.
These GUIDs and interfaces are found in Visual Studio 2005's netcon.h header file.
Has anyone had success implementing these interfaces and, if so, how?
|
|
|
|
|
hi all
can u plz tell me what is this line for
int *(*table())[30];
and if its an array or a variable how can i access it ?
thanks
|
|
|
|
|
At first glance, it appears to be an array of function pointers that return a pointer to an int . The array may belong to the return type, however.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
This is ultimately a function declaration.
It states that the function table() will return a pointer to an array of 30 pointers to int.
Here is an example using an array of 3 pointers to int:
int *(*oops())[3];<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
int *x[3];<br />
int *(*z)[3];<br />
z = &x;<br />
<br />
int *a[3];<br />
int *(*b)[3];<br />
b = &a;<br />
b = oops();<br />
<br />
return 0;<br />
}<br />
<br />
int *(*oops())[3]<br />
{<br />
int m = 0;<br />
int n = 1;<br />
int p = 2;<br />
int *a[3];<br />
a[0] = &m;<br />
a[1] = &n;<br />
a[2] = &p;<br />
return &a;<br />
}
|
|
|
|
|
Very good
The oops function needs a modification though: All the internal stack variable need to be changed to static or the address of the returned array and all the pointer it contains will be invalid after leaving the function.
int *(*oops())[3]
{
static int m = 0;
static int n = 1;
static int p = 2;
static int *a[3];
a[0] = &m;
a[1] = &n;
a[2] = &p;
return &a;
}
int main()
{
int* (*t)[3] = oops();
for( int i=0; i<3; ++i )
std::cout << *(*t)[i] << std::endl;
return 0;
}
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Are you sure it isn't int* (*table)()[30] ? (Note the position of the empty () ). That would mean
table is a pointer to a function
which takes no parameters
and returns an array of 30 int*
I can't tell you from just trying to manually parse it what it means to have (*table()) instead of (*table)()
|
|
|
|
|
Intellisense calls it "int **table"
|
|
|
|
|
thank u all for the clear replies
but why we need to say that the pointer is for array of 30 int pointers
its not enough to know the first pointer of the array to access its content ?
thanks
|
|
|
|
|
Ayman,
Ultimately the writer of the function chose to have the function return this type. C and C++ compilers then enforce type safety forcing you to interpret this complex type.
Certainly the writer could have had the function returned an int pointer. Doing so, however, probably did not give the function caller what the function writer predicted the caller would want.
If you are the function caller, you probably know best if the writer correctly predicted what you wanted. If the writer was wrong, maybe you want to rewrite the function or wrap the function to return what you want?
|
|
|
|
|
Hi all,
How can make the output not to repeat again for many players. here is part of code.
struct
{
int face;
unsigned int value;
}
card[13] =
{ {'2', 2},{'2', 3},{'2', 4},
{'5', 5},{'6', 6},{'7', 7},
{'8', 8},{'9', 9},{'X', 10},
{'J', 13},{'Q', 12},{'K', 11},
{'A', 1}
};
char suit[4]={'D','C','H','S'};
ex of output is (1 player): D9 ,H2,SQ....
(2 player) : CX,H8,D9...
D9 came to second time again!!!
sometimes cards repeat only in 1 player !! pls help me to solve out.
|
|
|
|
|
See
[^]
I also suggested to write an article on such thing (is somewhere a volunteer?)
Hope that helps.
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.
|
|
|
|
|
The simplest solution would be to expand the definition of a card to include the suit; that will also simplify the code dealing with the individual cards.
If you only wish to use a single array to keep track of all the cards, as implied, I would also add a value to the card definition that indicates if the card has been dealt, discarded, or is still available in the deck.
Additionally I would separate the card structure definition from the array declaration so that you would have more flexibility.
If I was creating a card game then a card would be in one of three places:
The Deck: Cards waiting to be dealt (not in play yet).
The Discard Pile: Cards that are out of play.
A Users Hand: Cards that are still in play.
Depending on the game there may be a fourth place (or others):
On the Table: Cards that are in play but available to every one (like in Texas Hold-em).
Ultimately the best way to insure that the cards never repeat is to place them in one and only one location at a time. If the card is in a player's hand then it can not also be in the deck or discard pile, if the card is in the discard pile it can not also be in the deck or the player’s hand.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi all,
I need to create a win32 service that logs all the user events when started on a client machine. That is, once the service is started, I need to be able to detect that the user has clicked on an icon, typed text, etc.... and log all these entries in a simple text file. I have no problem with creating a Win32 service and creating a log file, but I really don't know how to detect the GUI events.... any ideas?
Thanks a lot!
-- narada
|
|
|
|