|
Just dont do it. Think of your thread as being in a different process, how would you communicate between them? With PostMessage and SendMessage. So create some custom IDs, handle them in your main window proc and post or send using those IDs from the thread.
You have to keep it clean on Windows, you cant bodge stuff. It might work for a bit, but eventually it will break.
|
|
|
|
|
Thanks, that's exactly how I did it over the weekend and it works well.
PKNT
|
|
|
|
|
Hi there,
Is there a way to disallow users from pasting anything to CEdit box control?
Right now they can right click and select the PASTE menu option.
And also do a Control + V.
How to disable this?
please give some sample code.
Thanks in advance.
|
|
|
|
|
|
Oh, but he said "Please give me some code". Are you sure he can handle a link? It might involve thinking....
|
|
|
|
|
Erudite_Eric wrote: might involve thinking
If 99% of the people asking questions here actually put forth any effort in thinking, then 99% of the questions would disappear....
|
|
|
|
|
Here you go:
<pre> if (add_uevent_var(env,
"MODALIAS=usb:"
"v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
le16_to_cpu(copy_dev->descriptor.idVendor),
le16_to_cpu(copy_dev->descriptor.idProduct),
le16_to_cpu(copy_dev->descriptor.bcdDevice),
copy_dev->descriptor.bDeviceClass,
copy_dev->descriptor.bDeviceSubClass,
copy_dev->descriptor.bDeviceProtocol,
alt->desc.bInterfaceClass,
alt->desc.bInterfaceSubClass,
alt->desc.bInterfaceProtocol))
return -ENOMEM;
modified 18-Jul-13 9:11am.
|
|
|
|
|
Hi,
I'm using wofstream to write text to a file
my problem is that, with any level of optimization, neither write() or << allows me to write a wstring or c string in the form of (WCHAR*).
example
WCHAR* str = new WCHAR[MAX_PATH];
wcscpy(str, L"walk");
myfile.write(str, wcslen(str));
No string written to file
wstring str2 = L"walk";
myfile << str2;
No string written to file
I am able to to do
myfile << "String";
how do I fix?
|
|
|
|
|
Unfortunately you don't. The wstream types take wide characters in but write them out as normal ASCII. You should use the old C-style fwrite or the newer WriteFile functions which allow you to specify the output character size.
Use the best guess
|
|
|
|
|
so wofstream can't be optimized? it all works well without optimization
|
|
|
|
|
doug25 wrote: so wofstream can't be optimized? it all works well without optimization Sorry, I don't understand what you are saying here. As far as Irecall from all the tests I have run, you cannot write wide characters via a wstream. I would be interested to see the code you have that does work. In the meantime I will retry my own tests.
Use the best guess
|
|
|
|
|
sorry, I've discovered what was happening, it isn't a problem with wstring optimazation. I was converting the file to another format the functions i'm using behave differently with optimization.
The problem is nothing to do with vectors or wstrings. it's a directx set of functions i'm using that fail when optimazation is turned on. It was difficult to determine tat this was where the program was failing.
modified 17-Jul-13 12:17pm.
|
|
|
|
|
doug25 wrote: the functions i'm using behave differently with optimization. I find that very difficult to believe. Much more likely is that you have a bug somewhere that only shows when you have optimization turned on.
Use the best guess
|
|
|
|
|
well, it could be a mistake I've made but I've managed to find exactly where the error occurs by using #pragma optimize("g", off)
and
#pragma optimize("g", on)
it's one function, I can't see any mistakes
#pragma optimize("g", off)
void AddDataObject(ID3DXFileSaveObject* xFileSave, ID3DXFileData* child, ID3DXFileSaveData* xSaveData)
{
SIZE_T nChildren = 0;
child->GetChildren(&nChildren);
GUID templateid, id;
child->GetType(&templateid);
child->GetId(&id);
char name[MAX_PATH];
SIZE_T sz;
child->GetName(name, &sz);
SIZE_T dataSize;
void* data = NULL;
child->Lock(&dataSize, (LPCVOID*)&data);
if(xSaveData)
{
xSaveData->AddDataObject(templateid, name, (const GUID*)&id, dataSize, data, &xSaveData);
}
else
{
xFileSave->AddDataObject(templateid, name, (const GUID*)&id, dataSize, data, &xSaveData);
}
child->Unlock();
for(int i=0; i<nChildren; i++)
{
ID3DXFileData* ch = NULL;
if(SUCCEEDED(child->GetChild(i, &ch)))
{
AddDataObject(xFileSave, ch, xSaveData);
}
}
}
#pragma optimize("g", on)
|
|
|
|
|
What problem and where does it occur?
Use the best guess
|
|
|
|
|
the problem is some strings are not loaded, or at least are not written to the new file. e.g. each line in the output file that should contain "Frame frame_name {" (works without opt.) reads "Frame {".
I will try freeing the memory of child data objects although I have assumed they get released when the top level data object get released and I will try what Jochan suggested.
There is very little documentation on how to use these functions.
I won't be able to reply for a while if I do fix the problem but cheers.
|
|
|
|
|
doug25 wrote: the problem is some strings are not loaded, or at least are not written to the new file. e.g. each line in the output file that should contain "Frame frame_name {" (works without opt.) reads "Frame {". Now I'm totally lost; the code you posted does not seem to have anything at all to do with these comments. It may be better to close off this thread and start a new question when you are ready to proceed.
Use the best guess
|
|
|
|
|
I haven't explained it very well. Basically, I've written a program that writes a .x file using wofstream. But the file doesn't look very pretty so I'm using the directx code I posted to convert it to a better format, so I can also save it as binary or compressed as well as structured text. Basically saves me having to rewrite the program.
I'll close the thread.
|
|
|
|
|
|
You can just stop posting, or edit your original question and add "[closed]" or "[solved]" to the title, and a comment to the effect that you have closed it.
Use the best guess
|
|
|
|
|
That is a recursive function. You may generate assembler output to see the differences between the optimized and unoptimized code.
You should also check for success on all functions that may fail. At least the AddDataObject() return values should be checked and returned upon errors to leave the recursion if something wrent wrong.
|
|
|
|
|
|
Using VS2008 Prof. on Windows8, a Win32 ListView control in Report mode doesn't display any icons at the start of each row. It shows data which I can sort, but no icons.
I'm assuming its some bit or attribute not set somewhere so have to show all the relevant code for someone to see what I'm missing. The list (header)setup code is here (followed by the row insertion code taken out of its loop and then my test code). All error handling removed. I've compared this to an ATL/WTL program that shows the icons and I can't see any difference.
The image list is initialised by the CDeviceImageList constructor which uses the below code to initialize the list:
class CDeviceImageList
{
private:
SP_CLASSIMAGELIST_DATA m_spImageData; public:
CDeviceImageList()
{
RtlZeroMemory(&m_spImageData, sizeof(SP_CLASSIMAGELIST_DATA));
m_spImageData.cbSize = sizeof(SP_CLASSIMAGELIST_DATA);
BOOL b = SetupDiGetClassImageList(&m_spImageData);
if(FALSE == b)
{
assert(!"Failed to aquire class image list");
}
}
operator HIMAGELIST() const throw()
{
return m_spImageData.ImageList;
}
...
ListView setup before the data ...
LVITEM lvItem;
SecureZeroMemory(&lvItem, sizeof(LVITEM));
LVCOLUMN lvCol;
SecureZeroMemory(&lvCol, sizeof(LVCOLUMN));
HWND hList=GetDlgItem(hwnd,IDC_LIST1);
lvCol.pszText=L"Port"; lvCol.mask=LVCF_TEXT;
lvCol.cx=60; lvCol.mask |= LVCF_WIDTH;
lvCol.iSubItem = 0; lvCol.mask |= LVCF_SUBITEM;
lvCol.fmt = HDF_SORTUP; lvCol.fmt |= LVCFMT_LEFT; lvCol.mask |= LVCF_FMT;
int nCol = 0;
nCol = ListView_InsertColumn(hList, lvCol.iSubItem, &lvCol);
lvCol.iSubItem = 1; lvCol.pszText=L"Device"; lvCol.cx=220; nCol = ListView_InsertColumn(hList, lvCol.iSubItem, &lvCol);
lvCol.iSubItem = 2; lvCol.pszText=L"Manufacturer"; lvCol.cx=100; nCol = ListView_InsertColumn(hList, lvCol.iSubItem, &lvCol);
CDeviceImageList cImageList;
HIMAGELIST hImageList = cImageList;
HIMAGELIST hRet = ListView_SetImageList(hList, hImageList, LVSIL_SMALL,);
ListView_SetExtendedListViewStyle(hList, LVS_EX_INFOTIP | LVS_SHOWSELALWAYS);
At this point I can get the image list back from the ListView
The relevant row insertion code, after which I can get the icons, is below but the ListView doesn't display them...
LVITEM lvItem;
SecureZeroMemory(&lvItem, sizeof(LVITEM));
lvItem.mask=LVIF_TEXT; lvItem.cchTextMax = 0;
lvItem.iItem=n; lvItem.iSubItem=0; lvItem.pszText=m_pData[n]->szName;
lvItem.iImage = ImageIndex;
lvItem.mask |= LVIF_IMAGE;
lvItem.lParam=(LPARAM)m_pData[n];
lvItem.mask |= LVIF_PARAM;
HWND hList=GetDlgItem(hwnd,IDC_LIST1);
int nItemIndex = ListView_InsertItem(hList, &lvItem);
lvItem.lParam=0;
lvItem.mask &= ~LVIF_PARAM;
lvItem.iImage = 0;
lvItem.mask &= ~LVIF_IMAGE;
lvItem.iSubItem=1;
lvItem.pszText=(LPTSTR)(LPCTSTR)szData[n][1];
ListView_SetItem(hList, &lvItem);
lvItem.iSubItem=2;
lvItem.pszText=(LPTSTR)(LPCTSTR)szData[n][2];
ListView_SetItem(hList, &lvItem);
After each loop above I can use the following three lines to get the icons (and a few more to display them as proof). But the ListView still refuses to show them...
HWND hList=GetDlgItem(hwnd,IDC_LIST1);
HIMAGELIST hGotList = ListView_GetImageList(hList, LVSIL_SMALL);
HICON hIcon = ImageList_GetIcon(hGotList, ImageIndex, ILD_NORMAL);
modified 17-Jul-13 5:07am.
|
|
|
|
|
Hi,
How are you creating your image list? Are these 32 bit icons?
About Image Lists[^]
Best Wishes,
-David Delaune
|
|
|
|
|
David,
I've now added the code showing the creation of the image list to my question as you're not the only one to ask how it's created or initialized. Basically my CDeviceImageList constructor uses a call to SetupDiGetClassImageList[^].
At the end of my list setup and data initialization I can use the last three lines of code shown to basically: GetDialog, GetListView, and GetIcon followed by a call to
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); to display in the top-left corner of the dialog the very icon I expect to see in the ListView. which would seem to prove the ImageList in the ListView has the icons.
Are they 32 bit? Not to my knowledge.
I've read the stuff on ImageLists, ListViews etc. until I almost know it by heart.
|
|
|
|
|