|
It's what EnumResourceNames(Ex) gives you as a parameter when calling the function you specify via the ENUMRESNAMEPROC function pointer parameter.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
But ENUMRESNAMEPROC also requires lpName. what is that?
|
|
|
|
|
Noooo - when you call EnumResourceNames, it'll call the function you specify once for each name it finds. It will pass in the name it's just found, allowing you to store it somewhere or process it:
typedef std::vector<CString> Names;
BOOL CALLBACK GatherNames(
HMODULE hModule,
LPCTSTR lpszType,
LPTSTR lpszName,
LONG_PTR lParam)
{
Names* pNames = reinterpret_cast<Names*>(lParam);
pNames->push_back(CString(lpszName));
return TRUE;
}
void GetStringResourceNames(HMODULE module)
{
Names names;
EnumResourceNames(module, RT_STRING, GetherNames, reinterpret_cast<LONG_PTR>(&names));
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
This is the code we are using till now. Where are we going wrong?
#include "stdafx.h"
#include "windows.h"
#include "tchar.h"
#include "stdio.h"
#include "string.h"
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param);
char buffer[200];
int _tmain(int argc, _TCHAR* argv[])
{DWORD S;
LPCTSTR RT_String=NULL;
LONG_PTR aux_param=NULL;
BOOL q,r;
HMODULE some_library = LoadLibrary("C:/Hi/Debug/Hi.exe");
q= MyStringCB(some_library,RT_String,buffer,aux_param);
r=EnumResourceNames(some_library, RT_STRING, MyStringCB, aux_param);
S=GetLastError();
return 0;
}
BOOL CALLBACK MyStringCB(HMODULE some_library,LPCTSTR RT_String,LPTSTR buffer,LONG_PTR aux_param)
{ DWORD startId = ((DWORD)buffer - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{ LoadString(some_library, i,buffer,sizeof(buffer));
}
return TRUE;
}
|
|
|
|
|
Why didn't you take any notice of this answer[^] to one of your previous questions? His answer was completely accurate.
Here's what your MyStringCB should look like:
BOOL CALLBACK MyStringCB(HMODULE some_library, LPCTSTR resourceType, LPTSTR stringName, LONG_PTR aux_param)
{
_ASSERTE(resourceType == RT_STRING);
static TCHAR stringValue[2048];
UINT id;
if (IS_INTRESOURCE(stringName))
id = (UINT)stringName;
else if (_T('#') == stringName[0])
id = _tcstoul(stringName+1, 0, 10);
else
return TRUE;
DWORD startId = ((DWORD)id - 1) * 16;
DWORD i, endId = startId + 16;
for (i = startId ; i < endId; ++i)
{
std::fill_n(stringValue, 2048, (TCHAR)0);
LoadString(some_library, i, stringValue, 2048);
if (_tcslen(stringValue) > 0)
{
}
}
return TRUE;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to fire a non blocking message box so that it will not interupt the code below it . and I click OK on it with some message
Trioum
|
|
|
|
|
In that case, you need to make yourself a modeless dialog box[^] on which you can put your message.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmmm, this might work.
DWORD dwID =0;
MSGBOXPARAMS msg = {0};
msg.cbSize = sizeof(MSGBOXPARAMS);
msg.hwndOwner = this->m_hWnd;
msg.hInstance = GetModuleHandle(NULL);
msg.lpszText = _T("Blocking is for bullies.");
msg.lpszCaption = _T("Non-blocking");
msg.dwStyle = MB_OK | MB_SETFOREGROUND;
CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)MessageBoxIndirect,&msg,0,&dwID);
Make sure not to create the MSGBOXPARAMS on the stack you probably want it to be persistent. You might be able to check if the user has clicked the OK button by checking GetExitCodeThread Function[^] for STILL_ACTIVE.
Let me know if it works.
Best Wishes,
-David Delaune
|
|
|
|
|
How Could we make a field or fields of database primary key for that database using Dao Database?
CDaoTableDef tableDef(&m_db);
tableDef.Create(m_tableName.c_str());
tableDef.CreateField(m_field1.c_str(),dbText,1,dbFixedField);
tableDef.CreateField(m_field2.c_str(),dbText,255,dbVariableField);
tableDef.Append();
tableDef.Close();
I want to make my secound field primary key in my database.
|
|
|
|
|
I think you need to use the CreateIndex[^] method. The CDaoIndexInfo structure[^] lets you specify that an index is primary (i.e. the primary key) or foreign (foreign key).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi everyone,
I have a modal dialog box which is called by the main thread. This dialog has no parent (appears at center screen, overlapped, and shown in taskbar). When the user clicks "Save" in the dialog, the dialog procedure receives the command and displays a save file dialog (GetSaveFileName).
The problem is that the second dialog (Save Dialog) doesn't work at all. It can't be activated, and seems kind of frozen (can't be closed, buttons and scroll bars are frozen). Here's my code:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
DialogBox(hInstance, MAKEINTRESOURCE(101), NULL, DialogProc);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
HDC hdc; PAINTSTRUCT ps;
switch (message) {
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDSAVE:
OPENFILENAME OFN;
OFN.hwndOwner = hWnd;
[...]
if (GetSaveFileName(&OFN)) {[...]}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return true;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
break;
case WM_INITDIALOG:
[...]
return true;
case WM_CLOSE:
[...]
return true;
case WM_DESTROY:
[...]
return true;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return false;
}
Whatever dialog type I put at this line (print dialog, modal dialog, modeless dialog), it doesn't behave properly. What am I missing?
I tried with OFN.hwndOwner = NULL, but doesn't work.
Thanks in advance!
|
|
|
|
|
The problem may well be in the [...] stuff.
I know the OPENFILENAME struct has lots of members - some refer to hooks, and instances of replacement dialog templates, etc.
At the very least, put in a
memset(&ofn, 0, sizeof(ofn));
line! (Parameters from memory. If you do not check them, you may lose your home, etc).
Also, pretty critically, there's a lStructSize member of ofn too! I suspect this needs filling in.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
No it is not! The problem does not lie within the save file dialog, but rather within the dialog procedure and/or API calls. If I replace the save file dialog part with a print dialog or even a new modal or modeless dialog, the problem still occurs. The second dialog shows itself but is unusable.
Thanks for your reply though
|
|
|
|
|
Problem solved. The problem was within the procedure. Replaced "return DefWindowProc(hWnd, message, wParam, lParam)" by "return false". return DefWindowProc is for main windows, not dialogs.
|
|
|
|
|
Hi,
I am trying to write a small application, using Visual C++.
In the application's GUI, among other things, there will be 2 buttons:
First button should turn the PC's internal speaker ON.
Second button should turn the PC's internal speaker OFF.
The GUI will have to be functional during all times.
I see that in order to use the PC's internal speaker I need to use the Beep(int tone, int duration) function. (or is there any other way ???)
The problem is that Beep function will play sound and stop the code's execution until duration mSec will be over.
This is not good to me, as I will need the program to continue do other things in the background and I will need it to response to the OFF button as well.
Using a flag to repeat the short Beeps again and again in a loop produces a glitch in the sound, every time that the Beep is executed (looped) again, so this is not elegant solution that I wold like to use.
The solution that I came to is:
ON button will start a thread, that will Beep endlessly.
OFF button will Beep for 1 mSec, and this way will terminate sound that the Beep from the BeepThread started.
Note that the Beep's thread called from ON button will never finish execution as it will be stack in it's Beep() line that has endless time as parameter.
The problem in my solution is that even if the sound stops, the BeepThread that was started will never end, and pressing several times on the on/off buttons will produce several BeepThreads.
Killing a thread from the outside is not recommended as well.
Any ideas on how to deal with this issue ?
I am open to change the whole way of my solution.
Thanks.
|
|
|
|
|
Why dont you loop beep function with finite time inside the thread, say 5 seconds? This way when off is clicked the sound will stop immediately and thread will terminate in at most 5 seconds.
void thread_func()
{
while(!done)
{
beep(5000);
}
}
void off_func()
{
beep(1);
done = false;
}
-Saurabh
|
|
|
|
|
Thanks for your comment.
As I wrote before, I did so, but the problem is that this caused a short noise every time interval.
In the case of your suggestion, the noise will come out every 5 seconds.
The noise is an outcome of the beep being stopped and immediately started again, so the tone is not continuously.
This noise is a problem, as the tone that I produce should come out clean.
Any other suggestions ?
Thanks.
|
|
|
|
|
Hi,
Can anyone help me here ?
I would really appreciate getting ideas for my problem.
-- Amit.
|
|
|
|
|
Does anyone know what DLL the image of the standard image list IDB_VIEW_SMALL_COLOR is stored in? You can see some of it in this screenshot: http://www.airwebreathe.org.uk/IDB_VIEW_SMALL_COLOR.png[^]. I might expect it to be in comctl32.dll with other common image lists... but it's not - only the old 4-bit version of the image.
This is all helping the development of Wine (windows apps running on linux).
Joel Holdsworth
|
|
|
|
|
hi..
my current problem is i have message keep coming to my local system port from one of my networked computer..
that is through socket programming(using udp).. and the application which im running in my system is win32 not mfc based...
and my project doesn't allow me to use mfc (might sound strange.. where cAsynchronous class is the only solution for an asynchronous UDP socket, i googled so far..).. and if there is a way to read incoming message (asynchronously and doesn't block my execution..so that i run the rest of my processes which include my menu handling, and blah, blah, blah, is there is a message of some type i should read it as it comes.. otherwise do my rest of the processess)....
previously just to recieve some msg outside mfc using udp i worked with recievefrom and other recieve functions that come with udp socket class members.. (and i even don't need the need to notify the incoming message thats why i went to udp not tcp..)
so finally what i need is just recieve message buffer from my local port.. and my work is done...
|
|
|
|
|
I'd have a look at the following article:
http://www.flounder.com/kb192570.htm[^]
Basically - don;t touch MFC's socket objects with a barge pole - put socket code in a different thread, and post messages to your main UI thread.
Enjoy the read - and look at the other essays on that site.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hello all!
I use the visual c++. I got this error: fatal error C1852: 'Release\Autorun.pch' is not a valid precompiled header file
The pch creating when the compile progress,but when the compile complete then the pch file deleting.
Thanks for all helps!!
|
|
|
|
|
Have you tried a "rebuild all"?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi,
Please if you can advise on following questions on integration with QuickBooks.
1. I need to connect to QuickBooks database. How can I connect and retrieve data from QuickBooks?
2. What type of connection do you use to connect to database?
3. Is there some tool that makes it easier?
Please answer on any questions of this, if you have programmed with QuickBooks.
Thanks in advance
John T.
|
|
|
|
|
Don't spam the forums. You should choose one forum and ask your question on the one only. That's in the rules.
|
|
|
|
|