|
Hey fellas!
Just a quick question, does CB_FINDSTRINGEXACT expect a unicode string, an ansii string or what? The documentation[^] doesn't specify this. As far as i know I can use CString (TCHAR's...) in both Unicode and non-unicode builds with this message, with some messages there is a unicode and a non-unicode version of it, usually postfixed by W and A to indicate the difference, however, CB_FINDSTRINGEXACT is hardwired to be 0x0158 in winuser.h, there seems to be no CB_FINDSTRINGEXACTA and CB_FINDSTRINGEXACTW. So does the control somehow detect if it is getting a unicode or a non-unicode string when handling this message? Or if it was created with the unicode version of CreateWindow (CreateWindowW) then it will expect a unicode string while if it was created with CreateWindowA then a non-unicode string?
Thanks for any answers in advance.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Windows are either unicode or ansi depending on how they're created. If you send a message to a window from a window of a different type it marshalls the parameters.
Cheers,
Ash
|
|
|
|
|
Thanks for your answer.
So you mean if the combo box was created with the wide version of CreateWindow then it expects a wide character string, if it was created with the ansi then an ansi string?
Aescleal wrote: If you send a message to a window from a window of a different type it marshalls the parameters.
-i don't quite understand what you mean by this. If i send a message either with SendMessage or PostMessage there's no "from window" specified, how do you mean that?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Slight confusion there sorry about that - it's the version of SendMessage or PostMessage that determines how the parameters are marshalled. If you stick to one character type consistently in your app you shouldn't have a problem.
Cheers,
Ash
|
|
|
|
|
Ah, makes sense this way, thank you for enlightening me.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
It's actually the window class of the window that determines whether it's unicode or ansi - so it's RegisterWindowEX and not CreateWindowEx that determines the type of window.
One day I'll be competent at answering questions, until then I hope I haven't confused the issue too much.
Ash
|
|
|
|
|
No, it is clear now, or i am too confused to notice that i am confused. Thanks again for the info.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Computers are evil, EVIL i tell you!! <
|
|
|
|
|
Why is it usually can output "main thread is running" one more, because if I don't use "/MT" option?
#include <windows.h>
#include <iostream.h>
DWORD WINAPI Fun1Proc(LPVOID lpParameter);
void main()
{
HANDLE hThread1;
hThread1=CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);
CloseHandle(hThread1);
cout<<"main thread is running"<<endl;
}
DWORD WINAPI Fun1Proc(LPVOID lpParameter)
{
cout<<"thread1 is running"<<endl;
return 0;
}
this is the output result:
D:\Test>cl Thread.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
Thread.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:Thread.exe
Thread.obj
D:\Test>Thread
main thread is running
main thread is running
thread1 is running
D:\Test>cl Thread.cpp /MT
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
Thread.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:Thread.exe
Thread.obj
D:\Test>Thread
main thread is running
thread1 is running
D:\Test>
Why should that be?
|
|
|
|
|
/MT means that the standard runtime library code is properly interlocked so if you use a global object like cout you won't confuse it's internal state. Now quite what happened in your case I can't say not having used the compiler you're using for 8 years but it looks like it got confused when flushing the stream in one of the threads. Basically if you use multiple threads and the standard library without /MT (or the DLL equivalent) don't expect it to work!
Cheers,
Ash
|
|
|
|
|
Firstly, as mentioned by others, if you're using C runtime library functions (cout in your case) from a thread you've created then you should be using the multithreaded version (use the /MT option). A second but related issue is how you're starting the other thread. If you're creating a thread from which you're going to use CRT functions then you should use the one of the CRT's thread creation functions: _beginthread, _beginthreadex[^]. If you read the documentation for CreateThread[^] (the thread creation function you're using) it has the following warning:
A thread in an executable that calls the C run-time library (CRT) should use the _beginthreadex and _endthreadex functions for thread management rather than CreateThread and ExitThread; this requires the use of the multi-threaded version of the CRT.
Doing things the way you are results in calling CRT functions on a thread for which per-thread state has not been initialised. As a side note, if you had used _beginthread or _beginthreadex your application would have failed to compile when /MT was not used.
Steve
|
|
|
|
|
I attempted to bring a Window to the top, but it is only in case the focus is that same application.
Is their a way if I'm browsing chrome, I can bring that Window on top of it.
|
|
|
|
|
Try
SetForegroundWindow or ForceForegroundWindow or SetWindowPos or SwitchToThisWindow
or this, but it might not work.
#include <windows.h>
char title[500];
HWND WindowHandle;
BOOL CALLBACK MyEnumProc(HWND hWnd, LPARAM lParam)
{
GetWindowText(hWnd, title, 500);
if(strstr(title, "SomeTitle"))
{
WindowHandle = hWnd;
return FALSE;
}
return TRUE;
}
int main(int argc, char *argv[])
{
EnumWindows(MyEnumProc, 0);
SwitchToThisWindow(WindowHandle,TRUE);
system("PAUSE");
return EXIT_SUCCESS;
}
|
|
|
|
|
Hello.
I am confuse. Because of some snippet codes that any work I do can't solve them.(2-dimension arrays. like n[][])
1-a program to get countries and then print the capital of them.
Please give me an example.
2-multiplication of two arrays.(like x[m][n]*y[n][k]).
3- a code to get name and some grades of some students and then print them.(like other it should use dimensional array)
I know it is not accorded to agreement of this site. but I AM CONSTRAINED.
I promise to compensate it.
If you can help me please don't withhold.
THANK A LOT.
|
|
|
|
|
hasani2007 wrote: I know it is not accorded to agreement of this site.
Which means that we cannot do it; please understand people here give their time freely, but they do not have the time to write your programs.
hasani2007 wrote: but I AM CONSTRAINED.
That is not our problem.
hasani2007 wrote: I promise to compensate it.
If you wish to pay for support please go to the Jobs forum.
It's time for a new signature.
|
|
|
|
|
It's last time I do this work.
If you can & if you know anything about it please help me.
I request benediction for you from God.
HELP ME>>>I AM IN PRESSURE>>>HELP ME
|
|
|
|
|
Sorry, but I really don't have the time to do your work for you; and if I did it would not help as you would still not understand it. Here is a link[^] to some tutorials and other pages to help you. I am sure that if you need it you will be able to find something similar in your own language.
It's time for a new signature.
|
|
|
|
|
hasani2007 wrote: 1-a program to get countries and then print the capital of them.
Please give me an example.
2-multiplication of two arrays.(like x[m][n]*y[n][k]).
3- a code to get name and some grades of some students and then print them.(like other it should use dimensional array)
Why don't you try yourself? The above requirements are quite easy to fulfill, just some basic programming knowledge is needed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: some basic programming knowledge
if that is lacking then?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The he should move the request to QA: we have the MysticalPowers tag there.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: The he should move the request to QA: we have the MysticalPowers tag there
he hehe good one!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
hasani2007 wrote: 1-a program to get countries and then print the capital of them.
Please give me an example.
2-multiplication of two arrays.(like x[m][n]*y[n][k]).
3- a code to get name and some grades of some students and then print them.(like other it should use dimensional array)
dear, please refer thinking in c++ book on net, it' free! download from mindview.net
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello,i study the windows via c/c++.but i have some problems about this routine.
//Wiews must always start on a multiple of the allocation granularity
SYSTEM_INFO sinf;
GetSystemInfo(&sinf);
//Open the data file.
HANDLE hFile = CreateFile(TEXT("C:\\HugeFile.Big"), GENERIC_READ, FILE_SHARE_READ\
, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
//Create the file-mapping object.
HANDLE hFileMapping = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
DWORD dwFileSizeHigh;
_int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);
qwFileSize += (((_int64)dwFileSizeHigh) << 32);
//we no longer need access to the file object's handle.
CloseHandle(hFile);
_int64 qwFileOffset = 0, qwNumOfos = 0;
while(qwFileSize > 0)
{
//Determine the number of bytes to be mapped in this view
DWORD dwBytesInBlock = sinf.dwAllocationGranularity;
if(qwFileSize < sinf.dwAllocationGranularity)
dwBytesInBlock = (DWORD)qwFileSize;
PBYTE pbFile = (PBYTE)MapViewOfFile(hFileMapping, FILE_MAP_READ, (DWORD)(qwFileOffset >> 32), (DWORD)(qwFileOffset & 0xFFFFFFFF), dwBytesInBlock);
//Count the number of 0s in the block.
for(DWORD dwByte = 0; dwByte < dwBytesInBlock; dwByte++)
{
if(pbFile[dwByte] == 0)
qwNumOfos++;
}
//Unmap the view; we don't want multiple views in our address space.
UnmapViewOfFile(pbFile);
//Skip to the next set of bytes in the file.
qwFileOffset += dwBytesInBlock;
qwFileSize -= dwBytesInBlock;
}
CloseHandle(hFileMapping);
i can't understand the qwFileSize += (((_int64)dwFileSizeHigh) << 32);
and (DWORD)(qwFileOffset >> 32), (DWORD)(qwFileOffset & 0xFFFFFFFF)
can you tell me something? thank you.
|
|
|
|
|
See the description for GetFileSize()[^].
This code is taking the two result values and creating the 64-bit composite value, by shifting the high order bits 32-bits left, casting the result to an _int64 and adding to the low order value.
_int64 qwFileSize = GetFileSize(hFile, &dwFileSizeHigh);
qwFileSize += (((_int64)dwFileSizeHigh) << 32);
This code is extracting the two 32-bit halves of the value and passing them to the MapViewOfFile() function. In both cases the results need to be cast to DWORD s to keep the compiler happy.
PBYTE pbFile = (PBYTE)MapViewOfFile(hFileMapping, FILE_MAP_READ,
(DWORD)(qwFileOffset >> 32),
(DWORD)(qwFileOffset & 0xFFFFFFFF),
dwBytesInBlock);
It's time for a new signature.
|
|
|
|
|
|
Hello all.
I am programming a simple program in win32 console.
#include <stdio.h>
#include <conio.h>
main()
{
int i,j;
char list[80][20];
for(j=0;j<5;j++)
{
for(i=0;i<50;i++)
{
list[i][j]=getchar();
if (list[i][j]=='\n') break;
}
}
for(j=0;j<5;j++)
{
for(i=0;i<50;i++)
{
putchar(list[i][j]);
}
}
}
It should give some char and then print them. but when it want to print some other things (&%^&*vjc) print.
|
|
|
|