To use a CToolBarCtrl object, you will typically follow these steps:
1. Construct the CToolBarCtrl object.
2. Call Create to create the Windows toolbar common control and attach it to the CToolBarCtrl object. Indicate the style of toolbar by using styles, such as TBSTYLE_TRANSPARENT for a transparent toolbar or TBSTYLE_DROPDOWN for a toolbar that supports drop-down style buttons.
3. Identify how you want the buttons on the toolbar displayed:
(1)•To use bitmap images for buttons, add the button bitmaps to the toolbar by calling AddBitmap.
(2)•To use images displayed from an image list for buttons, specify the image list by calling SetImageList, SetHotImageList, or SetDisabledImageList.
(3)•To use string labels for buttons, add the strings to the toolbar by calling AddString and/or AddStrings.
I don't understand step 3, (1),(2),(3) I could use either one of it(like only use (2)only), or I can use (2) and (3) together.
Sorry for not fully understanding to read the MSDN.
I have a multithreaded app that has been successfully using CAsyncSockets to talk to non windows sockets for some time. I have also created CAsyncSockets in their own threads to talk to other instances of this app and it worked fine years ago under Windows 98.
Trying to run it now under XP it stops receiving OnReceive callbacks after an indeterminate time - sometimes just one or two seconds, sometimes a couple of minutes or so. When the callbacks stop, other network apps on the machine also fail (i.e. Internet Explorer, Ping, Net Browser, Shared drives etc all stop working ) until I exit the app.
I have checked the network with WireShark, and the packets are still coming in as expected, just OnReceive is not called. Calls to close socket still work, and reconnecting restarts it again for a short while.
I have slowed the transmission of the packets down to just one 20byte packet per second - it still locks up.
I have called GetSockOpt(SO_ERROR..... No indication of any error.
I have even replaced CAsyncSocket with CAsyncSocketEX from elsewhere on this site and I get exactly the same results.
I am, of course, using a UI thread not a worker thread so a message pump gerts to handle the messages properly.
I have tried it on many different systems all give same problem.
I have managed to move this forward a little in that the application works well under Windows NT4.0.
Problem is now clearly a windows XP platform problem. With my server application running on Windows XP, and the Client on Windows NT4.0 it all works as expected.
With the client (same .exe file) running on Windows XP arrival of the ethernet packets fail to call the OnReceive function after somewhere betweeen one second and a couple of minutes. When this happens, all other Ethernet comms on the system lock up until the socket in the client is closed.
Your code probably just seemed to be working before.
With XP (and again with Vista) the system threading
performance has improved greatly and that can really expose
old problems - usually thread related.
its a question of looking inwards, not outwards....
I was doing nothing in the the OnReceive that I thought could create a problem but it was an unguarded CPtrList.AddTail followed a little later (in same procedure) with a CPtrList.RemoveHead. Guarding these with a CSingleLock fixed the problem...
Though I don't see why that should be necesary as only references to this list are these two in this function, and this function is only ever called as the OnReceive on this single socket in its own thread.... unless WinSock can generate multiple (overlapping) calls? Is that possible?
Ok my code is below, my program is working okay so far but I am trying to implement the concatenate function and I have no clue how to do so. I am passing the second list to the concatenate function but I am unsure of how to create a pointer that would point to the first node of that second list object. I have a pointer created that points to the fist node of the first list but I don't know how to make one for the second list. How do I do this?
I am trying to implement the concatenate function and I have no clue how to do so.
There are two ways, depending on how you want concatenate() to work. If you want to copy the data from your second list and append it to the end of the first list, simply traverse the second list, extract the value and use your insert() method to append the data to the first list.
If your intention is to link the two lists together, simply find the last *next pointer in your first list and point it to the head of the second list.
Some notes on your code: When traversing your lists, sometimes you compare against NULL and sometimes you compare against 0. Keep it consistent. It's probably better to always use NULL.
Your insert() method isn't really an insert method. It is an append method. It always adds the record to the end of the list. It makes more sense (to me, at least) that the insert() method should add the record just before your NewList *current pointer.
Also, your class maintains a *current pointer which will never point to anything other than *head (i.e. it's only set in insert()). *current should probably be used to keep track of the current read position in your linked list so your users can actually use the list. You need a getData() method and a next() method which would allow users to read a record and move to the next record in the list. You should also include a rewind() method to set the *current pointer back to the beginning of the list.
I am creating application to track the usage of Function keys in the system. For that purpose i installed a system wide hook. The program also have an interface which the user can configure various settings . The hook is installed in the InitDialog of this dialog. User can also minimize the dialog to system tray. The problem is that the hook works only when the dialog is visible. If the user minimizes the app to the system tray the hook stops processing messages.
//Inside the Globalhook.dll
__declspec(dllexport) void InstallHotkeyHook()
hHotkeyHook = SetWindowsHookEx(WH_KEYBOARD, HotkeyMessageProc, hMod, 0); // hMod is taken from dllmain.
The above function is called to install the hook from InitDialog.
The hook is installed in the InitDialog of this dialog.
How will it work then? You are expecting to install a global keyboard hook - So, the hook should be installed from within a system-wide DLL, so that it could continue to process the hook messages. If it were installed from within a dialog which is not system-wide, and would work only when the dialog thread is active.
Step 1. Create a DLL and write the hook procedure in the DLL.
In the "apps" InitInstance I seed the random number generator by calling srand(time(NULL));
Then in a thread whenever I invoke rand() and print it out via cout it always has the value of 18467. Now rand() is invoked every minute or two so it's not like it's in a tight loop or anything like that. I never call srand again either. Just the once in the apps InitInstance function.
Anyone experienced this problem before? Currently using Visual Studio 2008. I even went so far as to apply SP1 to it just incase something was fixed. Such a simple thing not working is really annoying me.
Just to add if I print out rand() a few times in the apps InitInstance it works as expected. However once I call it from a UI thread it's always the same number.
Hi i am new to the concepts of vc++.
In my application i used a dropdown box where the user cab either pick the value from the dropdown or enter his own choice,after entering the value if the user is hitting the enter button my application is closing
i used the follwoing code in my pretranslate msg it is woking fine for all other controls except this dropdown box
if (pMsg->wParam == VK_RETURN)
//Call events on enter
PostMessage(WM_COMMAND, (BN_CLICKED << 16) | GetFocus()->GetDlgCtrlID(),(ULONG)GetDlgItem(GetFocus()->GetDlgCtrlID())->m_hWnd);
Can anybody suggest me the right approcah for doing this....
Hello. I have worked on some 2D development but now I am heading into 3D development and was wanting to create a virtual world but I really dont know how to. I would be grateful if someone could help me. If you want more information about the project I will be happy to tell you.
That's not a trivial task. The easiest solution is to use an existing 3D engine: Irrlicht, Ogre3D, OpenSceneGraph, ...
The first two ones are targeted specifically for games. So I would suggest the last one (see here[^]). I never used it myself but I heard good things about it.
You could of course develop the 3D engine yourself but looking at your question, it will probably be very difficult.
Thanks for the quick reply. I have decided not to use a 3D engine for different reasons. I have already scripted a lot of files but now its the stage of scripting the source code. I have used the 3d engine for other projects but now I want to build it using my own source code with some help.
Well, then you will need to learn either OpenGL or DirectX, then learn how to render 3D scene (I suggest a good book on that because you will spend probably too much time if you have to search for that on the web) and also probably some math. Anyway, this can't simply be answered on a forum because it is really big.
I have already scripted a lot of files but now its the stage of scripting the source code.
See when I have finished learning OpenGL or DirectX what will be the next stage.
learn what a scene graph is, and how to write your own. I use open scene graph for a lot. One advantage is that I have written my own "back in the day." I understand the desire to learn from the inside out and I commend you for the desire. Study how the various scene graphs work, their advantages and disadvantages and how you want to style your own. In the end it helps you understand why the various groups made the decisions they did. It may help you keep your own, or choose one of the existing groups and support them. In the end I chose OSG, but I can do more with it because I understand it internally.
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
Last Visit: 31-Dec-99 18:00 Last Update: 21-Jun-21 1:32