|
Then this should work:
m_Ctrl.Create( WS_CHILD|WS_VISIBLE, CRect(0,0,100,100), this, ID_SOMEID );
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
{Remember i am trying to create this control from a UIThread so a container for holding the control is missing, i am tryin to get the round about way if it exists so}
Okie i was successful in getting my code compiled with the following statement
BOOL CUIStatusThread::InitInstance()
{
// TODO: perform and per-thread initialization here
AFX_MANAGE_STATE(AfxGetStaticModuleState());
myctrl.Create("My window", WS_CHILD|WS_VISIBLE, CRect(0,0,100,100), AfxGetMainWnd(), ID_SOMEID );
return TRUE;
}
but it gives a Debug Assertion Failure in occcont.cpp Line 62 on this statement -
ASSERT(pParentWnd != NULL);
I guess this should make the picture clear for u.
dimple
|
|
|
|
|
I am using SetCursor and LoadCursor to change the cursor.
m_hCursor = ::LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_BUTTON));
m_hOldCursor = SetCursor(m_hCursor);
I have this code in OnInitDialog() in a dialog based application but the cursor doesn't seem to change to my cursor. I have also Tried using IDC_HAND which is a windows cursor incase my cursor was bad. I also change AfxGetInstanceHandle to NULL in LoadCursor with no luck. In the debuger, m_hCursor and m_hOldCursor have valid address but my cursor doesn't seem to change....
Anyone?
Thanks
Ralph
|
|
|
|
|
You need to handle the message WM_SETCURSOR via the virtual handler OnSetCursor. The function is called repeatedly, so it should be optimized. In this handler and in the OnMouseMove handler is where you would call SetCursor.
onwards and upwards...
|
|
|
|
|
Try this code:
<br />
BOOL CSystemTray::SetIcon(UINT nIDBigIcon, UINT nIDSmallIcon, CStatic *pWndList, int nListNumber)<br />
{<br />
ASSERT (!nListNumber || (NULL != pWndList));<br />
m_hIcon = AfxGetApp()->LoadIcon(nIDBigIcon);<br />
m_hSmallIcon = AfxGetApp()->LoadIcon(nIDSmallIcon);<br />
ASSERT ((NULL != m_hIcon) && (INVALID_HANDLE_VALUE != m_hIcon));<br />
ASSERT ((NULL != m_hSmallIcon) && (INVALID_HANDLE_VALUE != m_hSmallIcon));<br />
if ((NULL == m_hIcon) || <br />
(INVALID_HANDLE_VALUE == m_hIcon) ||<br />
(NULL == m_hSmallIcon) || <br />
(INVALID_HANDLE_VALUE == m_hSmallIcon))<br />
return FALSE;<br />
<br />
CDialog::SetIcon (m_hIcon, TRUE);<br />
CDialog::SetIcon (m_hSmallIcon, FALSE);<br />
if (nListNumber && <br />
(NULL == pWndList))<br />
return FALSE;<br />
int i;<br />
CStatic *pPt = pWndList;<br />
for (i = 0; i < nListNumber; i++, pPt++)<br />
{<br />
pPt->SetIcon (m_hIcon);<br />
}<br />
return TRUE;<br />
}<br />
where:
<br />
protected:<br />
HANDLE m_hCompletion;<br />
HICON m_hSmallIcon;<br />
HICON m_hIcon;<br />
<br />
This works great. I did not test it with icons loaded from different modules neither with string-named resources (only index-named ones).
Hope this help.
Regards,
Andrea
|
|
|
|
|
Hi !
I'm using CVS in the developpement of my application.
I'd like that in that About Box of my app, the actual version of my application is automatically updated by CVS.
I first did defined this in a file of my application : #define REV $Revision:$
and CVS automatically updates the value of this define.
The problem is that the number I get is actually the revision of one single file, where I'd like to have the version of my global application.
I haven't used cvs tags yet, and I don't know if this would be a solution : can I retrieve in my code the tag of a set of files ?
Would you have another solution to my problem ?
Thanks !
Jerome
|
|
|
|
|
<br />
void CDialog::OnMouseMove(UINT nFlags, CPoint point) <br />
{<br />
CPoint point;<br />
CWnd *wd;<br />
<br />
GetCursorPos(&point);<br />
if( (wd = WindowFromPoint(point)) )<br />
{<br />
SetCursor(LoadCursor(NULL, (wd->GetDlgCtrlID() == IDCANCEL) ? <br />
IDC_ARROW : IDC_WAIT));<br />
}<br />
}<br />
hello. i've got a lengthy op and therefore an hourglass as mouse cursor. it should stay that way while not pointing to the cancel button. i wrote the code above to accomplish this.
problem: my dlg has also got a toolbar and 2 radio buttons that seem to override all this; the mouse icon is always an arrow when i point on them.
can somebody help, please?
Я люблю русский язикь!
|
|
|
|
|
You should override OnSetCursor associated to the message WM_SETCURSOR so you get notified when the cursor is to be changed...
|
|
|
|
|
In my program I need to control the connecting time,which means that when I use connect() to connect another machine,I can set how many seconds before the function return.
if u can give me some hint,u will give me a big faver!
|
|
|
|
|
Before calling connect, add a call to set the socket up as non-blocking:
ULONG ulParam = 1;
ioctlsocket(m_hSocket, FIONBIO, &ulParam);
Then call connect as normal.
After calling connect, you can do a select (writing) with whatever timeout you want to see if the socket has connected - if the socket can be written to it is
connected.
Regards,
Simon
|
|
|
|
|
I have a project which is an MFC resource-dll .
It contains several .rc files.
Two of these .rc files contain Icons.
All the icons have different IDs and are decalred in this fashion :
IDI_MY_ICON ICON "icons\\test.ico"
This generates the error:
fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409
If I allow only one of the files to contain icons, everything works.
My question is what can I do about this ? Is there a way to tell one of the resource files to start from a different internal-index or something like that ? because it seems like the icons are simply colliding internaly... (remember they have different IDs)
thanks
|
|
|
|
|
The name IDI_MY_ICON is just a macro. The resource file will include a header file somewhere that has the numeric values of the definitions. Your header files have clashing declarations - two resources numbered 1.
Once you get beyond a single .rc file, I recommend managing your identifiers yourself, rather than relying on Visual C++ / Visual Studio. It isn't designed to manage multiple resource files.
|
|
|
|
|
the IDI_MY_ICON was just an example.
If I declare an icon with ID let's say 124 in one file, and another icon with ID 312 in the other file, I get this error.
That's why I said it seems like some internal collision...
The mere fact that two .rc files contained Icons (non-clashing icons) generated this error.
And what does the 'Name' field mean in the error-string ? all my IDs are much higher than 1...
|
|
|
|
|
I'm trying to create common contros by coding and not through the resource editor. The problem is that the controls simply do not appear. They're being created with the CPropertyPage being their parent and then calling ShowWindow(SW_SHOW) on them.
Anyone to help ?
Thanks.
|
|
|
|
|
Did you ::InitCommonControlsEx ?
Also try to fire up a spy++ to see if those controls were created and if there were, what is there position.
Edward
|
|
|
|
|
Is it possible to align the property sheets in a Dialog in a vertical fashion rather than the usual horizontal way on the top of the dialog???
|
|
|
|
|
Hi,
I am creating an app, very much similar to a mini database. Now my problem is, I need to execute a QUERY on tables. There will be only a max of 4 fields in the queries WHERE clause. Then I need to filter the data based on the WHERE condition supplied. Any suggestions on what sort of data structure should I go for ? ( I can even load the whole thing into memory at startup if reqd.,since memory is not a constraint. )
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Have you considered the CRecordset and CDatabase classes?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I want to develop the same in Plain C++, so that it can be ported to UNIX later.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Since "plain" C++ has no knowledge of databases, recordsets, files, and the like, what you want, AFAIK, is not possible. In order to provide support for these, you'll need a platform-dependent API. I do not know of one for both Windows and UNIX, although it's been 15 years since I worked on a UNIX box so something just might be available.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
HI,
I have a batch file which takes 11 arguments. 11th argument is the file name and if I try writing anything to that file, the system creates the file name from argument 1 and appends 0 to it.
eg.
@echo Something > "C:\Logs\%10"
If I run like this
xxx.bat a b c d e f g h i j k
It creates b0 file. But I want to create k0
Any idea??
- Prashant
|
|
|
|
|
Er.. funny "Visual C++" question
Anyway, I belive the only way is like this:
shift
@echo Something > "C:\Logs\%90"
|
|
|
|
|
But shift takes arguments 0 to 8. Here its 9 and does'nt work..
|
|
|
|
|
Batch files are limited to 10 (numbered 0-9) command-line arguments.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
No...
Save this as test.bat:
@echo off
@echo %0
:again
if {%1}=={} goto :EOF
@echo %1 %2 %3 %4 %5 %6 %7 %8 %9
shift
goto again
Then execute "test.bat a b c d e f g h i j k l m n o p q r s t u v w x y z"
And you will see it prints out all 26 paramaters. You can only directly refer to the first 9, 10 including the file name, but you can shift more in. See here http://www.jsiinc.com/SUBN/tip6700/rh6792.htm.
The only limit AFAIK is the "%*" will only pass the 9 parameters, so you can't pass more than 9 to say another batch file, unless you shift each one in and call setlocal to assign them their own local variable, then pass all of them.
|
|
|
|