|
I am using vc++ dialog based application.I have two dialogs.in the second dialog i have an editbox to give a camera ip.what i want is when i give the ip in the edit box in second dialog,the vlc control in first dialog should play it..any code..
|
|
|
|
|
EN_SETFOCUSor EN_CHANGE are not helpful?
|
|
|
|
|
Is there any way to achieve the following syntax:
typedef int nothrow;
class my_class {
public:
template<typename T> void *search(int what);
};
template<typename T> void *my_class::search(int what) {throw "error";}
template<> void *my_class::search<nothrow>(int what) {return 0;}
int main() {
my_class c;
c.search<nothrow>(42);
c.search(42);
}
MSVC8 "could not deduce the template argument for 'T'". I tried changing the declaration to template<typename T = void> void *search(int what); but unfortunately "default template arguments are only allowed on class templates."
Thanks for your time.
|
|
|
|
|
|
Hi All,
If you, from a command prompt, enter "NSLOOKUP <enter>", your system's default name server (name and address) are echoed to the output window. Does anybody know how the command determines this? I'm coding in C++.
Thanks in advance.
- Dale
|
|
|
|
|
I am having an exact same code that I use in two applications, but in one application it is using more time to complete than the other. In one application it completes at 413Hz while in another application it completes in 280Hz. I checked to see if they r running at different loads while executing that code, but its not the case. Here is the code -
BYTE *buf1_ptr;
BYTE *buf2_ptr;
buf1_ptr = buf_f;
buf2_ptr = buf_b;
for ( i=0; i < total ; i = i + 1 )
{
if (*(buf1_ptr)>=*(buf2_ptr))
*(buf1_ptr) = *(buf1_ptr)-*(buf2_ptr);
else
*(buf1_ptr) = 0;
buf1_ptr++;
buf2_ptr++;
}
thts all it is doing, but I am not sure why there is difference in execution time . The 'total' is same in both applications.
thanks
PKNT
|
|
|
|
|
how many times did you time them?
|
|
|
|
|
many times, both in debug and release modes.... I still dont understand why its like tht....
PKNT
|
|
|
|
|
There are several possible explanations. For example, if your code is in a small application, it may fit into the cache and be executed without having to read memory. (The cache is in the CPU, but memory is on external chips which take longer to read.) This would run faster.
A larger application wouldn't all fit into the cache, so it would have to read from memory more often, which would be slower.
A similar effect can occur with small/large amounts of data.
If your code is by itself in a function, the compiler may assign register variables to your pointers, which are fast. If the code is embedded in a larger function, the registers may be assigned to other variables, which would slow down your loop.
Another possible explanation: If one of the applications has significantly more TRUE values for the if statement, it will do many more times as much work, which will be slower.
|
|
|
|
|
Is there is a way I can use assembly code (with SSE instructions) in VC6, like we do in Visual Studio.NET?? Since I am doing BYTE subtraction, can I do parallel subtraction using processor cache efficiently and reducing the time taken by the loop?? Or is there any other efficent way to do this loop while reducing the time taken for execution??
thanks
PKNT
|
|
|
|
|
You can use assembly code with SSE instructions in VS6. Since the subtraction is conditional, that may give you a problem doing several of them in parallel.
You can reduce the time taken by doing loop unrolling [^] The basic idea is to do as much computation as you can in a row before branching. This lets the compiler do operand prefetching and out-of-order instruction execution.
|
|
|
|
|
Hi guys,
I am trying to design a chat application using windows sockets.I am using a LAN based internet connection.I can connect to other systems within the LAN.How do i connect to another system in the internet which has connected to the net through LAN or a proxy?
|
|
|
|
|
I've been using Microsoft's MSDN example[^] as a starting point for my menu. This has been a bit frustrating, since some of the code simply doesn't work: SetMenuItemInfo() fails in their example until you set the cbSize of the MENUITEMINFO structure, which is explained in a different MSDN article.
Rather than using the MYITEM structure they do, I have created a class for my menu objects. Since my menu is created dynamically, I don't populate the menu structure when receiving the WM_CREATE message as they do in the example, but I am backpacking a pointer to a class item onto the MENUITEMINFO structure when menu items are created, like so:
MenuItem * myItem = &item;
MENUITEMINFO mii;
mii.fMask = MIIM_FTYPE | MIIM_DATA;
mii.fType = MFT_OWNERDRAW;
mii.dwItemData = (ULONG_PTR) myItem;
mii.cbSize = sizeof(mii);
SetMenuItemInfo(menu, item.itemID, FALSE, &mii);
In my function to handle the WM_MEASUREITEM message, I can access all of the class data from the pointer contained in the itemData member of the LPMEASUREITEMSTRUCT:
MenuItem *myItem = (MenuItem *) lpmis->itemData;
HDC hdc = GetDC(hwnd);
HFONT hfntOld = (HFONT)SelectObject(hdc, myItem->itemFont);
Microsoft use this exact same strategy when handling the WM_DRAWITEM message: they access the application-specific info from the itemData member of LPDRAWITEMSTRUCT. My implementation is the exact same as the example:
MenuItem *myItem = (MenuItem *) lpdis->itemData;
...
ExtTextOut(lpdis->lpdis->hDC,
x,
y,
ETO_OPAQUE,
&lpdis->rcItem,
myItem->itemLabel,
myItem->itemLabelLen,
NULL)
Sadly this strategy doesn't seem to work: any attempt to access the class items results in a crash. Is there some other sort of initialization I need to do that is missing from the example to ensure the pointer is passed along to the LPDRAWITEMSTRUCT? All examples of user-drawn menus that I've found on the site are MFC based. Here's hoping someone out there has some experience doing this in win32.
I'm also curious to find out if this may be an issue with the api that came with the mingw compiler that I'm using to compile and run my code...
Thanks in advance for any help or suggestions.
~g
|
|
|
|
|
How is your MenuItem class allocated? If you are storing pointers to a stack-alloated object, by the time you get to it in your handlers, it will have gone out of scope and you will have pointers to invalid memory.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thanks James... that must be it! I've made the following modification, but I'm still getting the same result...
MenuItem * myItem = (MenuItem *) LocalAlloc(LMEM_FIXED, sizeof(MenuItem)+256);
myItem = &item;
MENUITEMINFO mii;
ZeroMemory(&mii, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_FTYPE | MIIM_DATA;
mii.fType = MFT_OWNERDRAW;
mii.dwItemData = (ULONG_PTR) myItem;
The function containing this code receives a MenuItem object as a parameter (item). Should I be doing this allocation elsewhere?
Thanks again...
Greg
|
|
|
|
|
Is there a reason you're using LocalAlloc? it's obsolete. HeapAlloc supersedes LocalAlloc. And then operator new is recommended for c++ anyway. Try using new
|
|
|
|
|
I used LocalAlloc because that was what MS used in their example. The example is full of missed declarations and other problems; I've tried using the same data structure and memory allocation they do in the example, but populating it with the data from my class objects... that didn't work either.
I am now creating an object instance using the new operator as suggested...
MenuItem* myItem = new MenuItem;
myItem->SetValues(...);
...
MENUITEMINFO mii;
...
mii.dwItemData = (ULONG_PTR) myItem;
As before, I can access the object data when handling the WM_MEASUREITEM message but it's still crashing the application when using the exact same method when handling the WM_DRAWITEM message.
From what I understand, the memory allocated by new should remain allocated until I call delete . Please correct me if I'm wrong but based on that, I shouldn't need any additional allocation such as HeapAlloc...
|
|
|
|
|
I totally restructured my code in order to simplify things and try to track down what is wrong. My menu is now generated after getting the WM_CREATE message rather than dynamically when the user clicks for simplicity's sake. Each object is created using the new operator and destroyed using delete after receiving the WM_DESTROY message. I implemented a linked list and wrote a function to iterate through them at any time during the program's execution. The objects are all accessible. Since the LPDRAWITEMSTRUCT->itemData didn't seem to ever contain a valid pointer to my info, I now use my own function to retrieve my item data, and no longer load a pointer onto the dwItemData member of MENUITEMINFO.
My application is now drawing the menu for regular menu items: hooray! But I am still getting a nasty crash bug when the item being drawn is a submenu. In the class constructor, if an item is a submenu, an HMENU object is created and assigned to a member variable. The submenu is then created using the following code:
AppendMenu(myMenu, MF_POPUP | MF_OWNERDRAW, (UINT)menuItem->GetSubMenu(), menuItem->itemLabel);
When the MF_OWNERDRAW flag is set for a popup menu, all the members of the LPDRAWITEMSTRUCT seem to go haywire. All other menu items work fine. If I remove the MF_OWNERDRAW flag, all the submenus works perfectly. The sad thing is, I am still needing to use the itemID member of the LPDRAWITEMSTRUCT to determine which menu item is being drawn!
Am I missing something in my initialization? Or, is there another way to determine the ID of the menu item being drawn other than lpdis->itemID?
Thanks! Almost there...
[Edit]
Apparantly AppendMenu and SetMenuInfo doesn't quite it for initializing the LPDRAWITEMSTRUCT. Using InsertMenuItem did the trick.
modified on Wednesday, June 18, 2008 7:45 PM
|
|
|
|
|
Does anybody know how to read the actual position of desktop shortcuts and move them to a desired position.
many thanks in advance...
MS
|
|
|
|
|
error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const C0_VIDEO_AVI_View::classC0_VIDEO_AVI_View" (?classC0_VIDEO_AVI_View@C0_VIDEO_AVI_View@@2UCRuntimeClass@@B)
Debug/CCC_Parser.exe : fatal error LNK1120: 1 unresolved externals
I am getting the above linker error in this line of code:
if(pWnd->IsKindOf( RUNTIME_CLASS( C0_VIDEO_AVI_View) ))
My C0_VIDEO_AVI_View class is derived from CView and has both runtime macros included.
IMPLEMENT_DYNCREATE(C0_VIDEO_AVI_View, CView)
DECLARE_DYNCREATE(C0_VIDEO_AVI_View)
If I delete DECLARE_DYNCREATE(C0_VIDEO_AVI_View) I get these errors
L:\0\0 Project\0 Project Template\V1\CCC_00\TabView_View.cpp(520) : error C2039: 'classC0_VIDEO_AVI_View' : is not a member of 'C0_VIDEO_AVI_View'
l:\0\0 project\0 project template\v1\ccc_00\framegrabbertestview1.h(16) : see declaration of 'C0_VIDEO_AVI_View'
L:\0\0 Project\0 Project Template\V1\CCC_00\TabView_View.cpp(520) : error C2065: 'classC0_VIDEO_AVI_View' : undeclared identifier
The C0_VIDEO_AVI_View was working OK until I tried to run RUNTIME_CLASS macro and I got his macro working fine in other classes.
I actually copied working code and just replaced the class in the RUNTIME_CLASS macro with C0_VIDEO_AVI_View and got this error.
As always, I appreciate your help and many thanks for reading.
Vaclav
|
|
|
|
|
does your C0_VIDEO_AVI_View class have a default constructor ? i think that's what the first linker error is complaining about.
|
|
|
|
|
Yes it does have a default constructor.
|
|
|
|
|
I'll try to run RUNTIME_CLASS macro some other way - after the class is constructed
|
|
|
|
|
See here[^] for details on the macros in question.
What seems to be going on is that you've correctly used DECLARE_DYNAMIC in the class definition but failed to use the IMPLEMENT_DYNCREATE macro in the .CPP file.
Steve
|
|
|
|
|
Not true,if I comment out //IMPLEMENT_DYNCREATE(C_Bitmap_View_, CView)I get the following linker errors.
Bitmap_View_.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall C_Bitmap_View_::GetRuntimeClass(void)const " (?GetRuntimeClass@C_Bitmap_View_@@UBEPAUCRuntimeClass@@XZ)
TabView_View.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const C_Bitmap_View_::classC_Bitmap_View_" (?classC_Bitmap_View_@C_Bitmap_View_@@2UCRuntimeClass@@B)
Debug/CCC_Parser.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
I have rebuild offending class from scratch and have no more linker errors related to RUNTIME_CLASS macro.
The remaining suspect is Gallery since the failing class was loaded from there. I had some weird problems with Gallery before.
Anyway, I do not have an energy to find out if the Gallery caused this problem.
Will try it later. Good night from Houston.
Vaclav
|
|
|
|